1 public class LinkedListTest {
2 public static main( String[] args ) {
4 LinkedList list = new LinkedList();
5 System.out.println( "list should have zero elements: "+list.size() );
7 list.push( (Object)new Integer( 3 ) );
8 list.push( (Object)new Integer( 4 ) );
10 System.out.println( "list should have two elements: "+list.size() );
12 Integer x = (Integer)list.pop();
13 x = (Integer)list.pop();
15 System.out.println( "should be a 3: "+x );
17 list.addLast( (Object)new Integer( 6 ) );
18 list.addLast( (Object)new Integer( 5 ) );
19 list.addLast( (Object)new Integer( 4 ) );
20 list.addLast( (Object)new Integer( 3 ) );
22 System.out.println( "Looking for list 6, 5, 4, 3: " );
23 System.out.print( " " );
24 Iterator i = list.iterator();
25 while( i.hasNext() ) {
26 System.out.print( i.next() + ", " );
28 System.out.println( "" );
35 System.out.println( "Removed 5, looking for list 6, 4, 3: " );
36 System.out.print( " " );
38 while( i.hasNext() ) {
39 System.out.print( i.next() + ", " );
41 System.out.println( "" );