Here you can find the source of listOf(Collection
public static <T> List<T> listOf(Collection<T> collection, T... elements)
//package com.java2s; //License from project: Open Source License import java.util.ArrayList; import java.util.Collection; import java.util.List; public class Main { public static <T> List<T> listOf(Collection<T> collection, T... elements) { return (List<T>) fillCollection(fillCollection(newList(), collection), elements); }//w w w . ja va 2s. c o m public static <T> List<T> listOf(Collection<T> collectionA, Collection<T> collectionB) { return (List<T>) fillCollection(fillCollection(newList(), collectionA), collectionB); } public static <T> List<T> listOf(T... elements) { return (List<T>) fillCollection(newList(), elements); } private static <T> Collection<T> fillCollection(Collection<T> myCollection, T[] elements) { if (elements != null) { for (T element : elements) { myCollection.add(element); } } return myCollection; } private static <T> Collection<T> fillCollection(Collection<T> myCollection, Collection<T> elements) { if (elements != null) { myCollection.addAll(elements); } return myCollection; } private static <T> List<T> newList() { return new ArrayList<T>(); } }