看不到图片
把我昨天的枚举Demo粘贴上来[code]public enum TrafficLamp
{
RED(45) {
@Override
public TrafficLamp nextLamp()
{
return GREEN;
}
} ,GREEN (50){
@Override
public TrafficLamp nextLamp()
{
return YELLO;
}
},YELLO(10) {
@Override
public TrafficLamp nextLamp()
{
return RED;
}
};
public abstract TrafficLamp nextLamp();
private int time;
private TrafficLamp(int time )
{
this.time=time;
}
}[/code]号称最难的枚举了 有抽象方法,有匿名内部类 |