How to convert List to Int Array in Java

We create a new list:

List<Integer> result = new ArrayList<Integer>();

Finally we convert it to int array and return this array:

return result.stream().mapToInt(i -> i).toArray();

Leave a Reply