LinkedList creation
In this chapter you will learn:
Create LinkedList
The following two methods create LinkedList
.
LinkedList()
Creates an empty list.LinkedList(Collection<? extends E> c)
Creates a list containing the elements of the specified collection, in the order they are returned by the collection's iterator.
import java.util.LinkedList;
// ja v a 2 s . c o m
public class Main{
public static void main(String args[]) {
LinkedList<String> ll = new LinkedList<String>();
ll.add("A");
ll.add("B");
ll.add("ja v a2s.com");
ll.add("E");
ll.add("F");
System.out.println(ll);
}
}
The output:
Next chapter...
What you will learn in the next chapter:
Home » Java Tutorial » List