Java Switch Statement

Java Switch Statement just like if-else ladder,its executes one code block from several conditions.

Java Switch Statement Syntax



Java Switch Statement Example

 Output of Above  Java Switch Statement:


One may ask what would happen if we did not use the break keyword in the above statement:

Try to execute below code :


Above Code Output:

Switch statement in java is a fall-through.This means that all the code will be execute once the first case it true.

Next Topic: Java For Loop


About the Author: Eric K

Kenyan Developer and Blogger with Interests in Java,Javascript,Node.js, Wordpress, Android, PHP and Making Money Online. Solving world problems through programming is my passion. Hire me: Email :