Java Reference
In-Depth Information
Iterable and Collection
Most of the core interfaces are rooted in
Iterable
and its
Collection
subinter-
face. Their generic types are
Iterable<T>
and
Collection<E>
.
Iterable
describes any object that can return its contained objects in some se-
quence.Thisinterfacedeclaresan
Iterator<T> iterator()
methodthatreturns
an
Iterator
instance for iterating over all the contained objects.
Collection
representsacollectionofobjectsthatareknownas
elements
.Thisin-
terfaceprovidesmethodsthatarecommontothe
Collection
subinterfacesonwhich
many collections are based.
Table 5-1
describes these methods.