| 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 ) | ||
|
|
You can get the freshest copy of this page from: | or possibly from your local J: drive (Java virtual drive/mindprod.com website mirror) |
| http://mindprod.com/jgloss/enumeration.html | J:\mindprod\jgloss\enumeration.html | |
![]() | ||
| Canadian Mind Products | ||
| mindprod.com IP:[65.110.21.43] | ||
| view Blog | Your face IP:[38.107.179.212] | |
| Feedback | You are visitor number 7,765. | |