LinkedList


LinkedList is available since Java 1.2

LinkedList extends AbstractSequentialList class.

Linked implements following Interfaces:
  • Serializable
  • Cloneable
  • Iterable<E>
  • Collection<E>
  • Deque<E>
  • List<E> 
  • Queue<E> 
The underlying data structure used is Doubly linked list.

LinkedList has two constructors:
  • LinkedList()
  • LinkedList(Collection c)             

Characteristics:
  • LinkedList allows null element.
  • LinkedList maintains insertion order of elements.
  • LinkedList is non-synchronized.
  • In LinkedList insertion and deletion operation are faster because there is not need of shift operation after insertion and deletion of element in List.
  • LinkedList class can be used to make list, stack and queue data structure.
Example:

import java.util.*; 
public class LinkedListFlight{ 
 public static void main(String args[]){ 
 
  LinkedList<String> linkedList = new LinkedList<String>(); 
  linkedList.add("A"); 
  linkedList.add("B"); 
  linkedList.add("C"); 
  linkedList.add("D"); 
  linkedList.add(null);     
  System.out.println(linkedList);      
 } 
}
 


Output
[A, B, C, D, null]