| Sample Code | Implementing |
| Generics | Learning More |
| Enumeration vs Iterator | Links |
If the class of interest supports both Iterator and Enumeration, use Iterator.
| Enumeration vs Iterator | ||
|---|---|---|
| Enumeration | Iterator Equivalent | Notes |
| Enumeration | Iterator | The name of the interface the doles out the elements one by one. |
| Hashtable.elements
Properties.propertyNames Vector.elements |
Collection.iterator | Typical name of method that provides the Enumeration or Iterator. |
| Enumeration.hasMoreElements | Iterator.hasNext | Are there more elements to come? |
| Enumeration.nextElement | Iterator.next | next element |
| java.lang.Iterable | Interface noting that this class is capable of emitting an Iterator with the iterator method. | |
| Works in a for:each statement, e. g. for ( String value : someCollection ) | ||
|
|
available on the web at: |
http://mindprod.com/jgloss/enumeration.html |
optional Replicator mirror
|
J:\mindprod\jgloss\enumeration.html | |
![]() |
Please email your
feedback for publication,
letters to the editor, errors, omissions, typos, formatting errors, ambiguities, unclear
wording, broken/redirected link reports, suggestions to improve this page or comments to
Roedy Green :
| |
| Blog | Canadian
Mind
Products
IP:[65.110.21.43] Your face IP:[107.21.156.140] |
|
| Feedback | You are visitor number 10,053. | |