Is it possible to go to the default case while I'm in case 1/2/etc.?
switch(num) {
case 1:
if(foo) {
//do something
} else {
//go to default
}
...
...
...
default:
//do something
}
Even if you change num
value when you are in switch
the value for comparision is the value of variable before start of switch so if you've entered one of case
branches you cannot enter again into default
.
However you can do something like
boolean doDefault = false;
switch(num) {
case 1:
if(foo) {
...
}
else {
doDefault = true;
}
break;
}
if(doDefault) {
//do something
}