Here you can find the source of toArray(List
public static int[] toArray(List<Integer> list)
//package com.java2s; //License from project: Apache License import java.util.List; import java.util.Set; public class Main { public static int[] toArray(List<Integer> list) { int[] result = new int[list.size()]; int index = 0; for (Integer number : list) { result[index++] = number;/* ww w .j a v a 2s . c o m*/ } return result; } public static int[] toArray(Set<Integer> set) { int[] result = new int[set.size()]; int index = 0; for (Integer number : set) { result[index++] = number; } return result; } }