File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/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
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: 37991
    
  22
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: 14074
    
  16

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: 79

Nice explanation .. thanks.


- Rohit
 
Don't get me started about those stupid light bulbs.
 
subject: Difference between lang.Enum and util.Enumeration
 
Similar Threads
Difference between Object and Instance
difference between encodeRedirectURL and encodeURL
doubt: equals&==
Difference between requestdispatcher and jsp:forward
Difference between attribute and parameter