Javatpoint Logo
Javatpoint Logo

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

Test it Now

Output:

Monday

Example 2: Multiple case labels

Test it Now

Output:

Monday

Example 3: case label holding an int value

Test it Now

Example 4: case label holding switch statement

Test it Now

Output:

BIT
Computer Department
Next TopicJava Tutorial




Help Others, Please Share

facebook twitter google plus pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA