Here you can find the source of toArray(ArrayList
static public int[] toArray(ArrayList<Integer> arrlist)
//package com.java2s; import java.util.ArrayList; public class Main { static public int[] toArray(ArrayList<Integer> arrlist) { int[] arr = new int[arrlist.size()]; for (int i = 0; i < arrlist.size(); i++) arr[i] = arrlist.get(i);/* ww w. ja v a 2 s. c o m*/ return arr; } }