Case expressions must be constant expressions for static final int?

Replace

 case MorrisBoard.RING.OUT:

with

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.

Leave a Comment