Java case keywordThe 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.SyntaxExamples of Java case keywordExample 1: case label holding the string valueTest it NowOutput: Monday Example 2: Multiple case labelsTest it NowOutput: Monday Example 3: case label holding an int valueTest it NowExample 4: case label holding switch statementTest it NowOutput: BIT Computer Department
Next TopicJava Tutorial
|