This week's book giveaway is in the General Computing forum.
We're giving away four copies of Arduino in Action and have Martin Evans, Joshua Noble, and Jordan Hochenbaum on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Difference between lang.Enum and util.Enumeration Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


JavaRanch » Java Forums » Java » Beginning Java
Reply Bookmark "Difference between lang.Enum and util.Enumeration " Watch "Difference between lang.Enum and util.Enumeration " New topic
Author

Difference between lang.Enum and util.Enumeration

Sony Agrawal
Ranch Hand

Joined: Oct 04, 2009
Posts: 143
I am confused about the difference between these two Enum...
I could not figure out anything
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 32827
    
    4
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

Joined: Oct 04, 2009
Posts: 143
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
Bartender

Joined: Aug 16, 2005
Posts: 12950
    
    3

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.


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
Rohit Mehta
Ranch Hand

Joined: Mar 11, 2005
Posts: 77

Nice explanation .. thanks.


- Rohit
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Difference between lang.Enum and util.Enumeration
 
Similar Threads
doubt: equals&==
Difference between Object and Instance
difference between encodeRedirectURL and encodeURL
Difference between attribute and parameter
Difference between requestdispatcher and jsp:forward