Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Difference between lang.Enum and util.Enumeration

 
Sony Agrawal
Ranch Hand
Posts: 143
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am confused about the difference between these two Enum...
I could not figure out anything
 
Campbell Ritchie
Sheriff
Pie
Posts: 50225
79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Completely different.

Enum is the superclass of all enumerated types, implicitly, the same way that Object is the superclass of everything. [Enum does extend Object.]
Enumeration is an interface which is hardly used any more. It is rather like Iterator.
 
Sony Agrawal
Ranch Hand
Posts: 143
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Campbell Ritchie wrote:Enumeration is an interface which is hardly used any more.

BUt some class methods of javax.servlet.* and javax.servlet.http.* package returns Enumeration STILL.
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15484
43
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Enumeration has more or less been replaced by Iterator since Java 1.2 (a LONG time ago...). The classes and interfaces in the Java EE packages that you mention were invented before that, so they (unfortunately) still use the old Enumeration interface. Sun doesn't want to change them, because that would make it incompatible with old Java programs.
 
Rohit Mehta
Ranch Hand
Posts: 79
Chrome Eclipse IDE Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Nice explanation .. thanks.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic