Can somebody explain to me why is the method Iterator
defined in java.util.Collection
? Collection already extends java.l
The Collection interface was introduced in Java 1.2 with the Collections API. The iterator
method was present then. However, the Iterable interface wasn't introduced until Java 1.5. The reason that Collection
explicitly defines iterator
is because it predates Iterable
. The idea of a Collection
returning an Iterator
predates the idea of Iterable
.