public class ListTest
1: // Fig. 17.5: ListTest.java
2: // ListTest class to demonstrate List capabilities.
3: import com.deitel.jhtp6.ch17.List;
4: import com.deitel.jhtp6.ch17.EmptyListException;
5:
6: public class ListTest
7: {
8: public static void main( String args[] )
9: {
10: List list = new List(); // create the List container
11:
12: // insert integers in list
13: list.insertAtFront( -1 );
14: list.print();
15: list.insertAtFront( 0 );
16: list.print();
17: list.insertAtBack( 1 );
18: list.print();
19: list.insertAtBack( 5 );
20: list.print();
21:
22: // remove objects from list; print after each removal
23: try
24: {
25: Object removedObject = list.removeFromFront();
26: System.out.printf( "%s removed\n", removedObject );
27: list.print();
28:
29: removedObject = list.removeFromFront();
30: System.out.printf( "%s removed\n", removedObject );
31: list.print();
32:
33: removedObject = list.removeFromBack();
34: System.out.printf( "%s removed\n", removedObject );
35: list.print();
36:
37: removedObject = list.removeFromBack();
38: System.out.printf( "%s removed\n", removedObject );
39: list.print();
40: } // end try
41: catch ( EmptyListException emptyListException )
42: {
43: emptyListException.printStackTrace();
44: } // end catch
45: } // end main
46: } // end class ListTest
47:
48:
49: /**************************************************************************
50: * (C) Copyright 1992-2005 by Deitel & Associates, Inc. and *
51: * Pearson Education, Inc. All Rights Reserved. *
52: * *
53: * DISCLAIMER: The authors and publisher of this book have used their *
54: * best efforts in preparing the book. These efforts include the *
55: * development, research, and testing of the theories and programs *
56: * to determine their effectiveness. The authors and publisher make *
57: * no warranty of any kind, expressed or implied, with regard to these *
58: * programs or to the documentation contained in these books. The authors *
59: * and publisher shall not be liable in any event for incidental or *
60: * consequential damages in connection with, or arising out of, the *
61: * furnishing, performance, or use of these programs. *
62: *************************************************************************/