I have struggling a bit with those 2 small errors because Eclipse IDE "said so." I will point out the errors. To be honest, I don't know how to explain deeply about those errors. I thought they were simple and I cannot get the errors to go away.
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);
and another error in my different class my package
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;
}