Site icon Narayana Tutorial

LinkedList

LinkedList

Constructors:-

creates an empty LinkedList objects.

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);
      }
}