switch Statement in Java


The switch statement is used for making a decision between multiple choices.

Source Code

int day = 4;
switch (day) {
    case 1:
        System.out.println("Monday");
        break;
    case 2:
        System.out.println("Tuesday");
        break;
    // more cases...
    default:
        System.out.println("Sunday");
        break;
}
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments