我试图检查在我的VO中设置的值。
下面是我的班级。我得到了限定大小写标签myenumt . usertype .DOCTORS必须被替换为限定enum常量DOCTORS"
请帮我找出我在这里做错了什么。
MyEnum.java
public MyEnum{
private UserType userType;
public UserType getUserType(){
return userType;
}
public void setUserType(UserType userType){
this.userType = userType;
}
public static enum UserType{
DOCTORS("D"),
PATIENT("P"),
STAFF("S");
}
}
EnumTest.java
public EnumTest {
.....
public void onGoBack(MyEnum myEnum) {
switch(myEnum.getUserType())
{
case UserType.DOCTORS: // this shows "The qualified case label MyEnum.UserType.DOCTORS must be replaced with the unqualified enum constant DOCTORS"
break;
}
}
}
由于编译器知道您在switch语句中计算的枚举类型,因此您应该根据错误提示(在您的情况下:MyEnum.UserType.
)删除"合格"部分,并简单地使用"不合格"enum DOCTORS
。见下文:
switch(myEnum.getUserType())
{
case DOCTORS:
break;
}