LinkedList class :

  1.  The underlying datastructure is Double Linked List.
  2.  Insertion order is preserved.
  3.  Duplicates are allowed.
  4.  Heterogeneous objects are allowed.
  5.  Null insertion is possible.
  6.  Linked List implements serializable and cloneable interfaces but not Random Access interfaces.
  7.  Linked List is the best choice if our frequent operation is insertion or deletion in the middle.
  8.  Linked List is the worst choice if our frequent operation is retrieval operation.
  9.  Usually we can use linked list to implement stacks and queues to provide support for this requirement Linked List class defines following specific methods.

Methods:

  • void addFirst();
  • void addLast();
  • Object getFirst();
  • Object getLast();
  • Object removeFirst();
  • Object removeLast();

CONSTRUCTOR:

Creates an empty Linked List object.

LinkedList l1 = new LinkedList();

 

Creates an equivalent Linked List object for a given collection.

LinkedList l1 = new LinkedList(Collection c);

Example of LinkedList :

Output :

[ccc, venkey, Software, 30, null, Preeti]

 

Leave a Reply