Here you can find the source of asArray(T[] arr, Iterator
public static <T> T[] asArray(T[] arr, Iterator<T> itr)
//package com.java2s; //License from project: Open Source License import java.util.*; public class Main { public static <T> T[] asArray(T[] arr, Iterator<T> itr) { ArrayList<T> lst = new ArrayList<T>(); while (itr.hasNext()) { lst.add(itr.next());/*w ww . j av a 2s .c o m*/ } Class tclass = arr.getClass().getComponentType(); return lst.toArray(arr); } }