I found that parentheses can be used in switch label, e.g.:
switch(id) {
case (CONSTANT):
case (1):
// Do action
break;
}
But why Java allow parentheses in this case, is there a use case ? because I can't use ||
or ,
to use multiple, e.g.
case (CONSTANT||1):
case (CONSTANT,1):
So why allow this syntax, I didn't find in JLS:
SwitchLabel: case ConstantExpression : case EnumConstantName : default : EnumConstantName: Identifier