Java tutorial
//package com.java2s; //License from project: Apache License import java.util.ArrayList; import java.util.Collection; public class Main { final static public Collection<Object> createCollection() { return new ArrayList<Object>(); } final static public Collection<Object> createCollection(int size) { return size > 0 ? new ArrayList<Object>(size) : createCollection(); } final static public Collection<Object> createCollection(Object object) { Collection<Object> collection = createCollection(); collection.add(object); return collection; } final static public Collection<Object> createCollection(Object[] objects) { Collection<Object> result = createCollection(); for (int i = 0; i < objects.length; i++) { result.add(objects[i]); } return result; } }