This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes enum question from K&B Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "enum question from K&B" Watch "enum question from K&B" New topic

enum question from K&B

Monica Dharwad

Joined: Aug 14, 2006
Posts: 8
in the following program, why is static main method able to access non static enum?

public class TestDays {
enum Days { MON, TUE, WED};
public static void main(String[] args) {
// TODO Auto-generated method stub
for(Days d : Days.values())
Days [] d2 = Days.values();
Vishwanath Krishnamurthi
Ranch Hand

Joined: Jun 04, 2007
Posts: 331
Nested enums are implicitly static.


I agree. Here's the link:
subject: enum question from K&B
Similar Threads
Problem in code
What is the use of colon ":" symbol in assigning the values for Enum ?
Need Clarity about Enum???
doubt in enums...anyone please help me out
Enums and operators