aspose file tools*
The moose likes Beginning Java and the fly likes Difference between lang.Enum and util.Enumeration Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Beginning Java
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: 36478
    
  16
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
Saloon Keeper

Joined: Aug 16, 2005
Posts: 13869
    
  10

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 attribute and parameter
difference between encodeRedirectURL and encodeURL
Difference between requestdispatcher and jsp:forward
Difference between Object and Instance