Here you can find the source of listToArray(ArrayList
public static int[] listToArray(ArrayList<Integer> tempList)
//package com.java2s; //License from project: Apache License import java.util.ArrayList; public class Main { public static int[] listToArray(ArrayList<Integer> tempList) { if (tempList.size() == 0) { return null; }/*from ww w .j a v a 2 s. c o m*/ int[] tempArray = new int[tempList.size()]; for (int i = 0; i < tempList.size(); i++) { tempArray[i] = tempList.get(i); } return tempArray; } }