How to convert an ArrayList containing Integers to primitive int array?
Posted
by Snehal
on Stack Overflow
See other posts from Stack Overflow
or by Snehal
Published on 2009-04-05T07:59:29Z
Indexed on
2010/04/30
13:27 UTC
Read the original article
Hit count: 202
java
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 convert in Java?
List<Integer> x = new ArrayList<Integer>();
int[] n = (int[])x.toArray(int[x.size()]);
© Stack Overflow or respective owner