In this tutorial, we are going to write a Java program to use nested switch case in java Programming with practical program code and step-by-step full complete explanation.
Java program to use Nested Switch.
public class NestedSwitchExample
{
public static void main(String[] args)
{
int i = 0;
int j = 1;
switch(i)
{
case 0:
switch(j)
{
case 0:
System.out.println("i is 0, j is 0");
break;
case 1:
System.out.println("i is 0, j is 1");
break;
default:
System.out.println("nested default case!!");
}
default:
System.out.println("No matching case found!!");
}
}
}
Output
i is 0, j is 1