Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
When programming with Collection, iterating over it is one of the most common tasks around. There are two ways to do this: by using Iterator and by using for.
Recall that Collection extends Iterable, which has one method: iterator. This method returns a java.util.Iterator that you can use to iterate over the Collection. The Iterator interface has the following methods: