How to convert an ArrayList containing Integers to primitive int array?

You can convert, but I don’t think there’s anything built in to do it automatically: public static int[] convertIntegers(List<Integer> integers) { int[] ret = new int[integers.size()]; for (int i=0; i < ret.length; i++) { ret[i] = integers.get(i).intValue(); } return ret; } (Note that this will throw a NullPointerException if either integers or any element within it is null.) … Read more