Here you can find the source of asArray(Collection c)
public static Object[] asArray(Collection c)
//package com.java2s; import java.util.Collection; import java.util.Iterator; public class Main { /** Returns an array with the elements in a given collection. */ public static Object[] asArray(Collection c) { Object[] array = new Object[c.size()]; int i = 0; for (Iterator it = c.iterator(); it.hasNext();) { array[i++] = it.next();/*from w ww. ja v a2 s . c o m*/ } return array; } }