楼主应该是看的这段代码吧?你既然定义了nextLamp方法为抽象方法,那么它的对象肯定要覆盖该抽象方法,不然的话编译是通不过的。你应该没有看完老师后面的代码吧。- public enum TrafficLamp{
- RED {
- @Override
- public TrafficLamp nextLamp() {
- // TODO Auto-generated method stub
- return null;
- }
- },GREEN {
- @Override
- public TrafficLamp nextLamp() {
- // TODO Auto-generated method stub
- return null;
- }
- },YELLOW {
- @Override
- public TrafficLamp nextLamp() {
- // TODO Auto-generated method stub
- return null;
- }
- };
- public abstract TrafficLamp nextLamp();
- }
复制代码
|