How to use enum in switch case

后端 未结 1 892
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-02-11 18:44

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:00

    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)
提交回复
热议问题