LinkedList

LinkedList

  • The underlying data structure for LinkedList is double LinkedList.
  • Insertion order is preserve.
  • Duplicate objects are allowed.
  • Heterogeneous objects are allowed.
  • Null insertion is possible.
  • Emplements Serializable & Cloneable interface but not Random Access.
  • LinkedList is not suitable if our frequent operation is not retrieval operation.

Constructors:-

  • LinkedList l = new LinkedList ();

creates an empty LinkedList objects.

  • LinkedList l = new LinkedList ( collection c )

In general, LinkedList an be used for implementing Stacks and Queue. To support this requirement LinkedList class define the following specific method.

  1. void add First ( object o )
  2. void add Last ( object o )
  3. void  remove First ( )
  4. void  remove Last( )
  5. void  get First ( ) ;
  6. void get Last ( );
import java. until. * ;
Class Exam LinkedList
{
 public static void main(string[] args)  
       {
          LinkedList l = new LinkedList ();
          l. add ( "narayana" );
          l. add (30);
          l. add (null);
          l. set ( o, "s/w" ) ;
          l. add ( o, anitha" );
          l. remove Last ();
          l. add First ( "ccc" );
          System.out.println (l);
      }
}

The Author

Narayanaswamy

Hello! I am Narayanaswamy founder and admin of narayanatutorial.com. I have been working in IT industry more than 7 years. NarayanaTutorial is my web technologies blog. My specialties are Java / J2EE, Spring, Hibernate, Struts, Webservices, PHP, Oracle, MySQL, SQLServer, Web Hosting and Website Development. I am a self learner and passionate about training and writing. I am always trying my best to share my knowledge through my blog.

Leave a Reply