V
Vinsoft Lab
Learn • Build • Grow
Programming Intermediate Paid

Java Programming

Learn Java programming from the fundamentals to object-oriented programming, collections, exception handling and practical application development.

8 Weeks 24 Lessons Practical Projects
Your Progress 0%
LESSON 10

Switch Statements

Use switch statements when a program needs to select between multiple possible cases.

Java Code

Study the example and understand what each part does.

JAVA
public class Main {

    public static void main(String[] args) {

        int day = 2;

        switch (day) {

            case 1:
                System.out.println("Monday");
                break;

            case 2:
                System.out.println("Tuesday");
                break;

            case 3:
                System.out.println("Wednesday");
                break;

            default:
                System.out.println("Other day");
        }
    }
}

Java code normally runs using the Java Development Kit on a computer, Android Studio or another Java development environment. This course page presents the code examples without pretending that the browser is running Java directly.

Expected Output / Result

Tuesday

Finished this lesson?

Mark it complete to update your course progress.

Quick Knowledge Check

Test your understanding of Java.

What keyword is used to create a class in Java?

Vinsoft Lab Academy

Build real programming skills.

Continue learning Java and explore practical programming, web development and mobile development courses.