/* * T01n02.java: The same exercising program from T01n01, but using the * Java LinkedList class and the ListIterator interface. Otherwise, it * doesn't show anything new. * * This version does not use Generics or any other Java 1.5 or later features. * See T01n04.java for a Java 1.5 version. */ import java.util.*; import java.util.LinkedList; // the util.* doesn't give access to this public class T01n02 { public static void main (String [] args) { LinkedList list; ListIterator sequence; list = new LinkedList(); System.out.println("The list contains " + list.size() + " items."); list.addLast(new Double (3.1415)); list.addLast(new Double (6.2830)); System.out.print("The list contains " + list.size() + " items: "); /* Use the list's iterator to help print the list content */ sequence = list.listIterator(); while (sequence.hasNext()) { Object object = sequence.next(); System.out.print(object + " "); } System.out.println(); } }