public class Test3 {
public static void main(String[] args) {
// TODO Auto-generated method stub
Lamp currentLamp = Lamp.Greenlamp;
System.out.println(currentLamp);
Lamp nextLamp=currentLamp.nextLamp();
System.out.println(nextLamp);
Lamp nextLamps=nextLamp.nextLamp();
System.out.println(nextLamps);
}
public enum Lamp{
//元素列表
Redlamp("Red","Green"),Greenlamp("Green","Yellow"),Yellowlamp("Yellow","Red");
//构造函数
private Lamp(String name,String next)
{
this.name=name;
this.next=next;
}
public String name;
public String next;
public Lamp nextLamp()
{ Lamp nextLamp=null;
if(next!=null)
{
nextLamp=Lamp.valueOf(next);
}
return nextLamp;
}
}
}
请问,这上面是什么错误?为什么编译器会报错呢?
|