You can not cast double[]
to an Double
, because of the obvious reason that they are just not COMPATIBLE.
If you are storing the double
values in double[]
and want to convert individual double
to Double
, you need not to typecast
explicitly. Autoboxing
works by default.
double[] val = {1.01, 3.09};
for(Double d : val){
// Make use of Double d here
}
2
solved Converting double[] to Double in java