Here you can find the source of fromArray(T[] array, Class
public static <C extends Collection<T>, T> Collection<T> fromArray(T[] array, Class<C> clazz)
//package com.java2s; //License from project: Open Source License import java.util.Collection; public class Main { public static <C extends Collection<T>, T> Collection<T> fromArray(T[] array, Class<C> clazz) { try {/*w w w . j av a2s. co m*/ Collection<T> collection = clazz.newInstance(); for (T o : array) { collection.add(o); } return collection; } catch (Exception e) { return null; } } }