The List#toArray()
of a List<Double>
returns Double[]
. The Double[]
isn't the same as double[]
. As arrays are objects, not primitives, the autoboxing rules doesn't and can't apply here.
Either use Double[]
instead:
Double[] array = list.toArray(new Double[list.size()]);
...or create double[]
yourself using a simple for
loop:
double[] array = new double[list.size()];
for (int i = 0; i < list.size(); i++) {
array[i] = list.get(i); // Watch out for NullPointerExceptions!
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…