/* * T01n04.java: The same exercising program from T01n01, but using the * Java LinkedList class and the ListIterator interface with Java 1.5's * Generics. Otherwise, it doesn't show anything new. */ import java.util.*; public class T01n04 { 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(); } }