代码如下:
- public enum WeekDay{
- SUN(1),MON(),TUE,WED,THI,FRI,SAT;
- private WeekDay(){System.out.println("first");}
- private WeekDay(int day){System.out.println("second");}
- }
-
- public enum TrafficLamp{
- RED(30){
- public TrafficLamp nextLamp(){
- return GREEN;
- }
- },
- GREEN(45){
- public TrafficLamp nextLamp(){
- return YELLOW;
- }
- },
- YELLOW(5){
- public TrafficLamp nextLamp(){
- return RED;
- }
- };
- public abstract TrafficLamp nextLamp();
- private int time;
- private TrafficLamp(int time){this.time = time;}
- }
复制代码 他说RED,GREEN,YELLOW是TrafficLamp的子类,子类是内部类的意思吗? 那不需要加class前缀吗?怎么理解这个。。。。
|
|