OO Programming with Java


Lists & Iterators

  1. Next, lists are used by the way of Iterators:
Iterator it = orders.iterator();
while(it.hasNext())
  System.out.println( it.next() );

This code can be simplified by using (a syntactic sugar):

for (Item i : orders) 
      System.out.println( i );

go further


6 - 13