All for Joomla All for Webmasters

Java LinkedList class

  • Java LinkedList class uses doubly linked list to store the elements. It extends the AbstractList class and implements List and Deque interfaces.
  • Java LinkedList class can contain duplicate elements.
  • Java LinkedList class maintains insertion order.
  • Java LinkedList class is non synchronized.
  • In Java LinkedList class, manipulation is fast because no shifting needs to be occurred.
  • Java LinkedList class can be used as list, stack or queue

ava LinkedList Example

  1. import java.util.*;
  2. public class TestCollection7{
  3.  public static void main(String args[]){
  4.   LinkedList<String> al=new LinkedList<String>();
  5.   al.add(“Ravi”);
  6.   al.add(“Vijay”);
  7.   al.add(“Ravi”);
  8.   al.add(“Ajay”);
  9.   Iterator<String> itr=al.iterator();
  10.   while(itr.hasNext()){
  11.    System.out.println(itr.next());
  12.   }
  13.  }
  14. }
Output:Ravi
       Vijay
       Ravi
       Ajay
PinIt
submit to reddit

Leave a Reply

Top