Java tutorial
//package com.java2s; import java.util.*; public class Main { public static <T> ArrayList<T> createArrayList() { return new ArrayList(); } public static <T> ArrayList<T> createArrayList(int initialCapacity) { return new ArrayList(initialCapacity); } /** *Description: */ public static <T> ArrayList<T> createArrayList(Iterable<? extends T> c) { ArrayList<T> list; if ((c instanceof Collection)) { list = new ArrayList((Collection) c); } else { list = new ArrayList(); iterableToCollection(c, list); list.trimToSize(); } return list; } public static <T, V extends T> ArrayList<T> createArrayList(V... args) { if ((args == null) || (args.length == 0)) { return new ArrayList(); } ArrayList<T> list = new ArrayList(args.length); for (V v : args) { list.add(v); } return list; } private static <T> void iterableToCollection(Iterable<? extends T> c, Collection<T> list) { for (T element : c) { list.add(element); } } }