switch case statement error: case expressions must be constant expression

后端 未结 9 1404
予麋鹿
予麋鹿 2020-12-04 07:51

My switch-case statement works perfectly fine yesterday. But when I run the code earlier this morning eclipse gave me an error underlining the case statements in color red a

9条回答
  •  爱一瞬间的悲伤
    2020-12-04 08:35

    Solution can be done be this way:

    1. Just assign the value to Integer
    2. Make variable to final

    Example:

    public static final int cameraRequestCode = 999;
    

    Hope this will help you.

提交回复
热议问题