Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

enum question from K&B  RSS feed

 
Monica Dharwad
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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();
System.out.println(d2[2]);
}
}
 
Vishwanath Krishnamurthi
Ranch Hand
Posts: 331
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Nested enums are implicitly static.

HTH,
Vishwa
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!