如何在开关情况下使用枚举
2022-09-01 09:41:00
我正在尝试检查我的VO中设置了哪些值。
下面是我的屁股。我得到“合格的病例标签MyEnum.UserType.DOCTORS必须替换为不合格的enum常数DOCTORS"
请帮我确定我在这里做错了什么。
我的记忆.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");
}
}
枚举测试.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;
}
}
}