public class Car
{
public enum User { "user", "computer", "na" };
private char car;
private final User user;
private boolean call;
public Car(char object, User user, boolean call)
{
this.car = car;
this.user = user;
this.call = call;
}
public User getUser()
{
return user;
}
public void setUser(User user)
{
this.user = user;
}
}
当我尝试编译时,我得到以下内容:
错误:预期
错误:',','}',或';'预期
error: '}' expected
禁止使用引号:
public enum User { user, computer, na };
您可以使用:
private enum User { USER, COMPUTER, NA }
另外,为了允许赋值,从user
的声明中删除final
关键字:
private User user;
创建一个新的Car
,你可以使用:
new Car('A', User.COMPUTER, true);
问题是:
中的双引号public enum User { "user", "computer", "na" };
删除它们:
public enum User { user, computer, na };