// I T E R A T O R , with generics, alternate import java.util.Iterator; import java.util.ArrayList; import static java.lang.System.out; //... Iterator<String> it = getAnIteratorOfSomeKind(); // Note the semicolon after hasNext(). for ( Iterator<String> iter = it; iter.hasNext(); ) { final String value = iter.next(); out.println( value ); }