The moose likes Java in General and the fly likes why Enum is declared abstract Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Java in General
Bookmark "why Enum is declared abstract" Watch "why Enum is declared abstract" New topic
Author

why Enum is declared abstract

Prasad Posani
Greenhorn

Joined: Mar 22, 2011
Posts: 4
Hello Friends,

what is the reason behind declaring java.lang.Enum as abstract, inspite of having no abstract method.

Regards
Prasad
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

from the API:
This is the common base class of all Java language enumeration types.


It is a base class which defines among other things a base Type, but it has no meaning on its own and hence requires a class to extend it to provide a real purpose.
An abstract class doesn't have to include abstract methods, it is just common to see that.
Prasad Posani
Greenhorn

Joined: Mar 22, 2011
Posts: 4
Hi,
thanks for the response.I feel the enums are somewhat confusing.I need one more clarification regarding enums.Why static methods cannot be declared in a constantspecific class body of the enum constants
Regards
Prasad
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

I'm not sure I understand your question, can you provide an example?
Mike Simmons
Ranch Hand

Joined: Mar 05, 2008
Posts: 3028
    
  10
Prasad Posani wrote:Why static methods cannot be declared in a constantspecific class body of the enum constants

What would it mean? Why would you need it?

By "constantspecific class body", I assume you mean the code (if any) associated with one particular instance of an enum class. Like

Why would you ever need or want to put a static method inside the places associated with specific instances? The point of the "static" keyword is that it's not associated with any instance. It's contradictory.
 
Have you checked out Aspose?
 
subject: why Enum is declared abstract
 
It's not a secret anymore!