| 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 ) | ||
![]() |
and suggestions to improve this page to Roedy Green : | ||
| Canadian Mind Products | |||
| mindprod.com IP:[65.110.21.43] | |||
| Your face IP:[38.103.63.18] | The information on this page is for non-military use only. | ||
| You are visitor number 14,403. | Military use includes use by defence contractors. | ||
| You can get a fresh copy of this page from: | or possibly from your local J: drive (Java virtual drive/Mindprod website mirror) | ||
| http://mindprod.com/jgloss/enumeration.html | J:\mindprod\jgloss\enumeration.html | ||