Java tutorial
//package com.java2s; //License from project: Apache License import java.util.*; public class Main { public static <T> List<T> dup(T o, int count) { List<T> ret = newArrayList(count); for (int i = 0; i < count; ++i) { ret.add(o); } return ret; } public static <T> ArrayList<T> newArrayList() { return new ArrayList<T>(); } public static <T> ArrayList<T> newArrayList(int initialCapacity) { return new ArrayList<T>(initialCapacity); } public static <T> ArrayList<T> newArrayList(Collection<T> initData) { return new ArrayList<T>(initData); } public static <T> ArrayList<T> newArrayList(T[] initData) { ArrayList<T> ret = new ArrayList<T>(initData.length); for (T t : initData) { ret.add(t); } return ret; } }