How to use enum in switch case

后端 未结 1 1304
醉梦人生
醉梦人生 2021-02-11 18:28

I am trying to check what values are set in my VO.

Below are my clasess. I am getting \"The qualified case label MyEnum.UserType.DOCTORS must be replaced with t

相关标签:
1条回答
  • 2021-02-11 19:15

    Since the compiler knows what type of enum you're evaluating in the switch statement, you should drop the "qualified" portion as the error suggests (in your case: MyEnum.UserType.) and simply use the "unqualified" enum DOCTORS. See below:

    switch(myEnum.getUserType())
    {
        case DOCTORS: 
            break;
    }
    
    0 讨论(0)
提交回复
热议问题