本帖最后由 我叫MT 于 2014-3-25 21:40 编辑
- public class Demo{
- public static void main(String[] args) {
- System.out.println(TrafficLight.GREEN);
- }
- public enum TrafficLight{
- RED{
- public TrafficLight nextLight() {
- return GREEN;
- }
- },GREEN{
- public TrafficLight nextLight() {
- return YELLOW;
- }
- },YELLOW{
- public TrafficLight nextLight() {
- return RED;
- }
- };
- public abstract TrafficLight nextLight();
- }
- }
复制代码 为什么调用GREEN时返回的不是yellow?哪里出问题了?
|
|