This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Static Enums 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 "Static Enums" Watch "Static Enums" New topic
Author

Static Enums

Gabriel Fairbanks
Greenhorn

Joined: Jul 30, 2004
Posts: 4
Hi,

I'm reading the K&B Java 5 Study Guide and I have a doubt. If I declare an ENUM inside a class, I can use the static modifier, but if I declare an ENUM outside, I still could use that ENUM inside a static method? (I know that I can't mark an outside ENUM as static).

Thank's

Gabriel Fairbanks
Burkhard Hassel
Ranch Hand

Joined: Aug 25, 2006
Posts: 1274
Hi cowboys,



yes you can use enums outside a class like a normal class


Example:



Prints out
CORAL
DAISY
ALGA



Yours,
Bu.


all events occur in real time
Gabriel Fairbanks
Greenhorn

Joined: Jul 30, 2004
Posts: 4
Thank you for the reply. The book don't mention that! I'll create some code to better understand that topic.

Thanks again!

Gabriel
 
 
subject: Static Enums
 
Similar Threads
Nested enum in enum.
Strange Enum behaviour?
Declaring Enums in a class
enum insid a class vs enum outside the class
switch