From charlesreid1

See Iterators vs Iterable

Iterators

  • Iterators are simple wrapper classes around references to locations in a container.
  • The Iterator class works a bit like a scanner, with methods to check if there is a next token, get the next token, and remove the last token returned.

Iterable

  • Iterable is the generic approach for getting some kind of iterator that will operate on this collection.
  • Implementing Iterable is what enables the use of for each syntax.





See also: