Iterable and Collection

Most of the core interfaces are rooted in Iterable and its Collection subinterface. Their generic types are Iterable<T> and Collection<E>.

Iterable describes any object that can return its contained objects in some sequence. This interface declares an Iterator<T> iterator() method that returns an Iterator instance for iterating over all of the contained objects.

Collection represents a collection of objects that are known as elements. This interface provides methods that are common to the Collection subinterfaces on which many collections are based. Table 8-1 describes these methods.

Table 8-1. Collection Methods

Was this article helpful?

0 0

Post a comment