Here you can find the source of toArray(Collection
public static double[] toArray(Collection<Double> values)
//package com.java2s; //License from project: Apache License import java.util.Collection; public class Main { public static double[] toArray(Collection<Double> values) { if (values == null) { throw new IllegalArgumentException("No null value allowed!"); }/*from w w w.j a v a 2s .c om*/ double[] result = new double[values.size()]; int cnt = 0; for (Double value : values) { result[cnt++] = value; } return result; } }