I\'m trying to convert an ArrayList containing Integer objects to primitive int[] with the following piece of code, but it is throwing compile time error. Is it possible to
I believe iterating using the List's iterator is a better idea, as list.get(i) can have poor performance depending on the List implementation:
list.get(i)
private int[] buildIntArray(List integers) { int[] ints = new int[integers.size()]; int i = 0; for (Integer n : integers) { ints[i++] = n; } return ints; }