由于 Eclipse IDE“这么说”,我在这两个小错误中遇到了一些困难。我会指出错误。老实说,我不知道如何深入解释这些错误。我认为它们很简单,我无法让错误消失。
ScheduledExecutorService timer = Executors.newScheduledThreadPool (1);
timer.scheduleAtFixedRate(new Runnable()
{
public void run()
{
if (lists. size ()> 0)
{
boolean lighted = Lamp.valueOf(Road.this.name).isLighted(); //According to Eclipse, "The method valueOf(Class<T>, String) in the type Enum<Lamp> is not applicable for the arguments (String)"
if (lighted)
{
System.out.println(lists.remove(0) + "is traversing!");
}
}
}
}, 1,1, TimeUnit. SECONDS);
和我的不同班级我的包中的另一个错误
public Lamp Blackout()
{
this.lighted = false;
if (opposite != null)
{
Lamp.valueOf(opposite).in.Blackout(); //in cannot be resolved or is not a field. It suggests me to create enum constant, which I did and it wouldn't work either.
}
Lamp nextLamp = null;
if (next != null)
{
nextLamp = Lamp.valueOf(next);
System.out.println("Green" + name () + "--------> switch to" + next);
nextLamp.light();
}
return nextLamp;
}