本帖最后由 王龙彪 于 2012-7-21 15:22 编辑
- enum TrafficLight
- {
- //RED, YELLOW, GREEN;
- RED
- {
- public TrafficLight nextLight()
- {
- return GREEN;
- }
- },YELLOW
- {
- public TrafficLight nextLight()
- {
- return RED;
- }
- },GREEN
- {
- public TrafficLight nextLight()
- {
- return YELLOW;
- }
- };
- public abstract TrafficLight nextLight();//为什么这句如果放在第一个对象的前面会报错呢
- }
复制代码 |
|