File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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 OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA 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: 4376

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