Skip to main content
IBM 
ShopSupportDownloads
IBM HomeProductsConsultingIndustriesNewsAbout IBM
IBM : developerWorks : Java : Education - online courses
Java Collections Framework
Download tutorial zip fileView letter-sized PDF fileView A4-sized PDF fileE-mail this tutorial to a friend
Main menuSection menuGive feedback on this tutorialPreviousNext
5. Historical collection classes
  


Enumeration interface page 4 of 7


The Enumeration interface allows you to iterate through all the elements of a collection. In the Collections Framework, this interface has been superceded by the Iterator interface. However, not all libraries support the newer interface, so you may find yourself using Enumeration from time to time.

UML Diagram for Map.Entry Interface

Iterating through an Enumeration is similar to iterating through an Iterator, though some people like the method names better with Iterator. However, there is no removal support with Enumeration.

Enumeration enum = ...;
while (enum.hasNextElement()) {
  Object element = iterator.nextElement();
  // process element
}

Main menuSection menuGive feedback on this tutorialPreviousNext
PrivacyLegalContact