Case expressions must be constant expressions for static final int?

狂风中的少年 提交于 2019-12-04 00:17:48

Replace

 case MorrisBoard.RING.OUT:

with

 case Ring.OUT:

So this will really be a constant as in "determined at compilation".

The specification precises that a "SwitchLabel" must be

  • case followed by a constant expression
  • case followed by the name of an enum value
  • or default

What is considered a valid constant expression is described here in the specification. It's fairly limited.

Simple solution for this problem is : Click on the switch and then press CTL+1, It will change your switch to if-else block statement, and will resolve your problem

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!