Java examples for Collection Framework:LinkedList
Constructs a new synchronized List based on a LinkedList .
//package com.java2s; import java.util.ArrayList; import java.util.Collections; import java.util.LinkedList; import java.util.List; public class Main { public static void main(String[] argv) { System.out.println(synchronizedList()); }//from w ww.j a v a2 s . com /** * Constructs a new synchronized {@code List} based on a {@link LinkedList}. * * @return a synchronized List */ public static <E> List<E> synchronizedList() { return Collections.synchronizedList(new LinkedList<E>()); } /** * Constructs a new synchronized {@code List} based on a {@link ArrayList} * with the specified {@code initialCapacity}. * * @param initialCapacity * the initial capacity of the array list * * @return a synchronized List */ public static <E> List<E> synchronizedList(final int initialCapacity) { return Collections.synchronizedList(new ArrayList<E>( initialCapacity)); } }