本帖最后由 adamjy 于 2014-4-22 12:36 编辑
枚举类有抽象方法,为什么枚举类不需要定义成抽象类型,代码如下
- 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;
- }
- },
- YELLOE {
- @Override
- public TrafficLamp nextLamp() {
- // TODO Auto-generated method stub
- return null;
- }
- };
- public abstract TrafficLamp nextLamp();
- }
复制代码 |