FileDocCategorySizeDatePackage
IteratorDemo.javaAPI DocExample789Sun Mar 07 18:42:18 GMT 2004None

IteratorDemo

public class IteratorDemo extends Object
Iterator used to walk through a List.
version
$Id: IteratorDemo.java,v 1.2 2004/03/08 00:42:18 ian Exp $

Fields Summary
Constructors Summary
Methods Summary
public static voidmain(java.lang.String[] argv)


		List l = new ArrayList();
		StructureDemo source = new StructureDemo(15);

		// Add lots of elements to the list...
		l.add(source.getDate());
		l.add(source.getDate());
		l.add(source.getDate());

		int i = 0;

		Iterator it = l.iterator();

		// Process the data structure using an iterator.
		// This part of the code does not know or care
		// if the data is an an array, a List, a Vector, or whatever.
		while (it.hasNext()) {
			Object o = it.next();
			System.out.println("Element " + i++ + " = " + o);
		}