Here you can find the source of toArray(Collection extends Integer> coll)
public static int[] toArray(Collection<? extends Integer> coll)
//package com.java2s; //License from project: Open Source License import java.util.Collection; public class Main { public static int[] toArray(Collection<? extends Integer> coll) { int[] target = new int[coll.size()]; int pos = 0; for (int i : coll) target[pos++] = i;/* w w w . j a va2s . c o m*/ return target; } }