85
Java case keyword
The Java case keyword is a conditional label which is used with the switch statement. It contains a block of code which is executed only when the switch value matches with the case.
A switch statement can contain multiple case labels. Each case label must hold a different value. The case label can contain the break statement that terminates the flow of the execution.
Note – The case does not hold the value of boolean, float and double type.
Syntax
Examples of Java case keyword
Example 1: case label holding the string value
Output:
Monday
Example 2: Multiple case labels
Output:
Monday
Example 3: case label holding an int value
Example 4: case label holding switch statement
Output:
BIT Computer Department
Next TopicJava Tutorial