本帖最后由 宿万涛 于 2011-11-22 16:40 编辑
public enum TrafficLamp {
RED{
public TrafficLamp nextLamp(){
return GREEN;
}
},
GREEN{
public TrafficLamp nextLamp(){
return YELLOW;
}
},
YELLOW{
public TrafficLamp nextLamp(){
return RED;
}
};
/* TrafficLamp nextLamp() {
return null;
}*/
public abstract TrafficLamp nextLamp();
}
请看注释部分,他跟public abstract TrafficLamp nextLamp();实现的是同样的nextLamp方法,请问这两种实现有什么区别? |