wood burning stoves 2.0*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes A static enumeration Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "A static enumeration" Watch "A static enumeration" New topic

A static enumeration

Mrinal Singhania

Joined: Sep 30, 2012
Posts: 7

The below code compiles fine even if the "static" keyword is removed for the enum declaration.

Can someone please explain?

Matthew Brown

Joined: Apr 06, 2010
Posts: 4343

From the Java Language Specification:
Nested enum types are implicitly static. It is permissible to explicitly declare a nested enum type to be static.

So it doesn't matter if you declare it as static or not, it will be treated as if it was.
It is sorta covered in the JavaRanch Style Guide.
subject: A static enumeration
Similar Threads
Enum Doubt
Where are these methods documented
enum question from K&B
doubt in enums...anyone please help me out