Java examples for java.util:List Creation
create Linked List from varargs
//package com.book2s; import java.util.Collection; import java.util.LinkedList; public class Main { public static final <E> LinkedList<E> createLinkedList(E... elements) { LinkedList<E> list = new LinkedList<E>(); addToCollection(list, elements); return list; }/*from w w w . j a va 2 s. c o m*/ public static final <E> void addToCollection( Collection<? super E> collection, E... elements) { for (E e : elements) { collection.add(e); } } }