if(array[3][3].getCall() == false && array[3][3].getUser() == Car.user.NONE )
{
array[3][3] = new Car('s', Car.user.USER, false);
aCounter++;
System.out.println("everything is fine");
}
这段代码给了我:错误:不能从静态上下文中引用非静态变量用户。
public class Car
{
public enum User { USER, COMP, NA };
private char object;
public User user;
private boolean call;
public Car(char object, User user, boolean call)
{
this.object = object;
this.user = user;
this.call = call;
}
}
枚举是公开的,因为否则我会得到“用户有私人访问错误”。我知道枚举是在构造函数中声明的非静态变量,所以我认为这是错误的来源,但我不知道如何修复它。