I have an ArrayList called out , and I need to convert it to double[] . The examples I found on the Internet said two things:
First try:
double[] d = new double[out.size()]; out.toArray(d);
However, this causes an error (eclipse):
The method toArray(T[]) in the type List<Double> is not applicable for the arguments (double[]).
The second solution I found was in StackOverflow and was:
double[] dx = Arrays.copyOf(out.toArray(), out.toArray().length, double[].class);
However, this causes an error:
The method copyOf(U[], int, Class<? extends T[]>) in the type Arrays is not applicable for the arguments (Object[], int, Class<double[]>)
What causes these errors and how to convert out to double[] without creating these problems? out really only contains double values.
Thanks!
java arraylist arrays list eclipse
Zyerah
source share