Using Switch
Switch Syntax
switch (expression) {
case value1:
// Code to execute if expression matches value1
break;
case value2:
// Code to execute if expression matches value2
break;
// More cases as needed
default:
// Code to execute if none of the cases match
}Example:
Aside: Java 12 Switch Cases
Last updated