Here you can find the source of asArray(Collection collection, E[] a)
static public <E> E[] asArray(Collection collection, E[] a)
//package com.java2s; //License from project: Open Source License import java.util.ArrayList; import java.util.Collection; import java.util.List; public class Main { static public <E> E[] asArray(Collection collection, E[] a) { return asList(collection).toArray(a); }//from w w w. j a v a 2s.c o m @SuppressWarnings("unchecked") static public <E> List<E> asList(Collection collection) { List<E> result = new ArrayList<E>(); for (Object obj : collection) { result.add((E) obj); } return result; } @SuppressWarnings("unchecked") static public <E> List<E> asList(Collection collection, E[] a) { List<E> result = new ArrayList<E>(); for (Object obj : collection) { result.add((E) obj); } return result; } }