• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

why Enum is declared abstract

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm not sure I understand your question, can you provide an example?
 
Master Rancher
Posts: 4806
72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic