File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Enums

 
Pradeep bhatt
Ranch Hand
Posts: 8927
Firefox Browser Java Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do enums extend java.lang.Object?
 
sanjeevmehra mehra
Ranch Hand
Posts: 75
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
enum (enumeration) is an interface and interfaces do not extend from Object class.


thanks & regards,
sanjeev.
 
Pradeep bhatt
Ranch Hand
Posts: 8927
Firefox Browser Java Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by sanjeevmehra mehra:
enum (enumeration) is an interface and interfaces do not extend from Object class.


thanks & regards,
sanjeev.


I am talking about enums in java Tiger and not Enumeration interface.
 
somkiat puisungnoen
Ranch Hand
Posts: 1312
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Pradeep Bhat:
Do enums extend java.lang.Object?



Sure, all class MUST extends java.lang.Object.



public abstract class Enum<E extends Enum<E>>extends Objectimplements Comparable<E>, SerializableThis is the common base class of all Java language enumeration types.
 
somkiat puisungnoen
Ranch Hand
Posts: 1312
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Enum is new feature in Java Tiger (5.0).

Typesafe Enums
This flexible object-oriented enumerated type facility allows you to create enumerated types with arbitrary methods and fields. It provides all the benefits of the Typesafe Enum pattern ("Effective Java," Item 21) without the verbosity and the error-proneness. Refer to JSR 201.
 
Mogens Nidding
Ranch Hand
Posts: 77
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, enums extend java.lang.Object!
In addition, they have high-quality toString, hashCode and equals methods. They are also Serializable and Comparable.
 
Gregg Bolinger
GenRocket Founder
Ranch Hand
Posts: 15302
6
Chrome IntelliJ IDE Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The Enum API is always a good place to find answers to questions like this.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic