You can use the toArray
to get an array of Integers
, ArrayUtils
from the apache commons to convert it to an int[]
.
List integerList = new ArrayList();
Integer[] integerArray = integerList.toArray(new Integer[0]);
int[] intArray = ArrayUtils.toPrimitive(integerArray);
Resources :
- Apache commons - ArrayUtils.toPrimitive(Integer[])
- Apache commons lang
- Javadoc - Collection.toArray(T[])
On the same topic :
- How to convert List to int[] in Java?