The Iterator
and ListIterator
provide complete facilities to iterate over collections. Indeed, the documentation for Iterator essentially says that Iterator
has superseded Enumeration
. Every collection is an Iterable
and therefore can be iterated using an Iterator
. Why then is there a method Collections.enumeration
that produces an Enumeration
over that collection?
The reason is that Enumeration
was present in the original Java 1.0 release, and Iterator
was not introduced until the collections framework was added in 1.2. Thus, there was a body of code and APIs that used Enumeration
. The Collections.enumeration
method was added to in order for (then) new collections-based code to adapt to old code that required the use of Enumeration
.