Lamp nextLamp = null;
if(next!=null){
nextLamp = Lamp.valueOf(next);
System.out.println("绿灯从"+name()+"-----------切换成------------"+next);
nextLamp.isGreen();
}
return nextLamp;
if(next!=null){--------------------------------------------------------------------------------->为什么用这种方法不会切换交通灯呢?它们的区别在哪里?
System.out.println("绿灯从"+name()+"-----------切换成------------"+next);
Lamp.valueOf(next).isGreen();
}
return Lamp.valueOf(next); |