public class EnumTest {
public enum TrafficLamp{
RED(30){
public TrafficLamp nextLamp(){
return GREEN;
}
},
YELLOW(5){
public TrafficLamp nextLamp(){
return RED;
}
};
public abstract TrafficLamp nextLamp();
private int time;
private TrafficLamp(int time){this.time = time;}
}
为什么枚举中的方法定义为抽象的,而枚举和外部类都没有定义为抽象的呢?看了好几遍视频,还是不理解请大家帮忙解决一下呗! |
|