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

previousnext

About the Author: Eric K

My name is Eric.Am a software developer with skills in Php,Mysql, Java , Android,Node.js Above all, I have certification in Cisco Networking Associate (CCNA) and holds degree in Information Technology. Hire me: Email : kawi3462@gmail.com