From charlesreid1

(Created page with "See Iterators vs Iterable")
 
No edit summary
 
Line 1: Line 1:
See [[Iterators vs Iterable]]
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.
[[Category:Java]]
[[Category:Iterators]]
[[Category:Iterable]]
{{CSFlag}}

Latest revision as of 00:51, 26 June 2017

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: