• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Enumeration interface

 
Ranch Hand
Posts: 226
Eclipse IDE Firefox Browser Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I have a question about this interface, what's different from iterator ?
and why some classes implement this interface instead of Iterator for example LIstResourceBundle?
Thanks in advance.
 
Ranch Hand
Posts: 239
12
Scala IntelliJ IDE Eclipse IDE Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The main difference is enumeration is intended to be basically read-only whereas iterator has a remove() method that can remove an element from the collection in question.
 
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Enumeration was around in the very early days of Java. It was basically a "first pass" at iteration. Collections were somewhat less organized in those days.

When Java 1.2 came out around 1998, they included a new Collections Framework. ArrayList is the preferred replacement for Vector, HashMap for Hashtable, and Iterator replaces Enumeration. The new classes have similar functionality to the ones they replace, but they were designed more cohesively to work together and be consistent as part of the framework, and to improve on the originals in various ways. However, by this time there was a lot of code already out there using Vector, Hashtable, and Enumeration, so they couldn't just get rid of them.

Dont' use Vector, Hashtable, or Enumeration unless you have to, due to interacting with legacy code.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic