TestIterator1.java
Select all
/* TestIterator1.java CIS 260 2/16/2005 David Klick Demonstrates how to use an Iterator. */ import java.util.*; public class TestIterator1 { public static void main(String[] args) { Vector v = new Vector(); for (int i=0; i<100; i+=10) v.add(new Integer(i)); // old school, no autoboxing Iterator iter = v.iterator(); while (iter.hasNext()) { System.out.print(iter.next() + " "); } } }