Java Collection Tutorial - Java LinkedList(Collection <? extends E > c) Constructor








Syntax

LinkedList(Collection <? extends E > c) constructor from LinkedList has the following syntax.

public LinkedList(Collection <? extends E> c)

Example

In the following code shows how to use LinkedList.LinkedList(Collection <? extends E > c) constructor.

import java.util.LinkedList;
/*  ww w  .  j a va2 s .  co  m*/
public class Main{
    public static void main(String args[]) {

        LinkedList<String> ll = new LinkedList<String>();


        ll.add("B");
        ll.add("ja v a2s.com");
        ll.addLast("E");
        ll.add("F");
        
        LinkedList<String> newList = new LinkedList<String>(ll);
        

        System.out.println(newList);
    }
}

The code above generates the following result.