Specifications
Sun Services
Java™ Programming Language
Module 9, slide 33 of 37
Copyright 2005 Sun Microsystems, Inc. All Rights Reserved. Sun Services, Revision F
Iterators
• Iteration is the process of retrieving every element in a
collection.
•AnIterator of a Set is unordered.
•AListIterator of a List can be scanned forwards
(using the next method) or backwards (using the
previous method).
List list = new ArrayList();
// add some elements
Iterator elements = list.iterator();
while ( elements.hasNext() ) {
System.out.println(elements.next());
}










