AdSense

AdSense3

Thursday, 27 August 2015

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.
java LinkedList class in collection framework

Java LinkedList Example

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

Output:Ravi
       Vijay
       Ravi
       Ajay

No comments:

Post a Comment