Java tutorial
//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 { Collection<T> collection = clazz.newInstance(); for (T o : array) { collection.add(o); } return collection; } catch (Exception e) { return null; } } }