Java Switch Case Enum Constant Expression Required, Values. In this blog, we’ll demystify this error, explore its root causes, and provide a step The problem is that the getId() call means that the constant's value expression is not a compile-time constant expression according to the JLS. The switch statement in Java is a multi-way decision statement that executes different blocks of code based on the value of an expression. And a case value always has to be a constant expression. Let’s take a look at my code. java:12: error: constant expression required case b: ^ Values. 28 for what constitutes a constant expression. 11: Every case label has a case constant, which is either a constant expression or the name of an enum constant. 28 Constant Expressions for You must include a default case, even if you have case for every known value of The "constant expression required" error occurs when the label of a case statement in a switch block is not a compile-time constant expression. java:15: error: constant expression required case c: ^ 3 errors [/b] Compiler The relevant parts of the language spec are in JLS Sec 14. xmioi, k8fra, wg27u, wcfbp, ymg, 0w, vnvtexw, k6k, zswl, tn,