package org.local; public class Test { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub System.out.println(weekday.A); System.out.println(TrafficLamp.YELLOW.nextLamp()); } public enum weekday{ A(1),B,C,D,E,F,G; private weekday(){}//实现私有构造方法 private weekday(int day){ System.out.println(day); } } public enum TrafficLamp{ RED {//内部匿名子类 @Override public TrafficLamp nextLamp() { // TODO Auto-generated method stub return GREEN; } }, GREEN { @Override public TrafficLamp nextLamp() { // TODO Auto-generated method stub return YELLOW; } }, YELLOW { @Override public TrafficLamp nextLamp() { // TODO Auto-generated method stub return RED; } }; public abstract TrafficLamp nextLamp(); } }