下面这个程序中,RED,GREEN,YELLOW这些是enum的子类还是enum的对象啊,我一直看不懂这个问题。请各位详解一下。。。。谢谢了
public class EnumTest {
public static void main(String[] args) {
}
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;}
}
}
|