public enum TrafficLamp{ //这个类里面有抽象方法,这里应该定义抽象类啊,怎么不是抽象类呢?不理解 RED(30){ public TrafficLamp nextLamp(){ returnGREEN; } }, GREEN(45){ public TrafficLamp nextLamp(){ returnYELLOW; } }, YELLOW(5){ public TrafficLamp nextLamp(){ returnRED; } }; public abstract TrafficLamp nextLamp(); privateint time; privateTrafficLamp(int time){this.time = time; }
|