> 
> **Possible Duplicate:**  
> 
> [How to convert an ArrayList containing Integers to primitive int array?](https://stackoverflow.com/questions/718554/how-to-convert-an-arraylist-containing-integers-to-primitive-int-array) 
> 
> 
> 

I tried the code below, but it does not work. Do I have to make a loop copy the `ArrayList` into an array ?

```
int[]intArray = (int[]) integerArrayList.toArray();

```