Home » java » Switch Statement in Java

Switch Statement in Java

Switch Statement in Java provides a way to select one option among multiple options.

In Java switch statement it provides multiple case statement  based on switch expression the appropriate case statement is get executed

The switch expression should be byte short int or char.
case label should also be one the above specified type and it should be constant or literal.
break statement is used to break the execution of switch statement
default should be last statement for any case label. If break is not used it execute all cases statement including default followed by currant case statement
The default statement is optional if expression does not match with any label then default case is executed.



Please follow and like us: