In the multiple selection:switch Statement , a in switch (a) can be either a base type expression or an enumeration type expression. The expression followed by the case also satisfies the following conditions:
- Compatible with an expression of a
- It should be a variable that cannot have a variable (that is, only the literal or final)
- Can't have two identical case
Also, be aware of the basic execution flow of the switch statement: switch matches the value of the expression to the value of the expression following the case, and if a match is found, then the case is executed, and if no match is made to the corresponding case, the default is encountered. Executes from default until the break statement is encountered or the entire switch statement ends.
Java Development Manual The 4th chapter of the learning Process Control process statements