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

why Enum is declared abstract

 
Prasad Posani
Greenhorn
Posts: 4
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13459
Android Eclipse IDE Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13459
Android Eclipse IDE Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not sure I understand your question, can you provide an example?
 
Mike Simmons
Ranch Hand
Posts: 3028
10
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Consider Paul's rocket mass heater.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic