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
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: 4541

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.
I agree. Here's the link:
subject: A static enumeration
It's not a secret anymore!