如何在 Java 中创建具有 "new" 值的 ENUM?
How to create an ENUM with a "new" value in Java?
如何将 new
作为值添加到 Java 中的枚举?
这是我的枚举:
public enum AgentProspectStatus
{
loose("loose"),
on_progress("on_progress"),
reached("reached"),
alumni("alumni"),
student("student"),
new("new"); // This throws an error
private String code;
AgentProspectStatus(String code)
{
this.code = code;
}
}
new("new")
行显示错误:
Unexpected Token
new
是 keyword in Java。在 Java 中,枚举应以大写形式拼写,并且 case_snake。更改大小写将修复您的错误。
public enum AgentProspectStatus {
LOOSE("loose"),
ON_PROGRESS("on_progress"),
REACHED("reached"),
ALUMNI("alumni"),
STUDENT("student"),
NEW("new");
private String code;
AgentProspectStatus(String code) {
this.code = code;
}
}
如何将 new
作为值添加到 Java 中的枚举?
这是我的枚举:
public enum AgentProspectStatus
{
loose("loose"),
on_progress("on_progress"),
reached("reached"),
alumni("alumni"),
student("student"),
new("new"); // This throws an error
private String code;
AgentProspectStatus(String code)
{
this.code = code;
}
}
new("new")
行显示错误:
Unexpected Token
new
是 keyword in Java。在 Java 中,枚举应以大写形式拼写,并且 case_snake。更改大小写将修复您的错误。
public enum AgentProspectStatus {
LOOSE("loose"),
ON_PROGRESS("on_progress"),
REACHED("reached"),
ALUMNI("alumni"),
STUDENT("student"),
NEW("new");
private String code;
AgentProspectStatus(String code) {
this.code = code;
}
}