i'm looking to cast an int
array to a double
one.
so, when i have
int arr[] = {1, 2, 3};
i want to use arr
, say pass it as a double[]
param
to a method.
what's the best way of doing this?
the cast
(double[])arr
doesn't work.
i can iterate thru arr
:
double[] dblA = new double[arr.length];
int ind=0;
for (int x:arr)
dblA[ind++]=x; // (double)x;
is there a better way of doing this?
System.arraycopy
isn't doing it-- doesn't work on arrays of two different primitive types.
Note: saw Casting Object to Array in Java and some other discussions.
TIA.