Sometimes it might be possible that we need to call some another case of switch statement after some processing in one case. In that case we can use either falling through switch cases or goto case statement. Here is the example of falling through - Falling through switch-cases can be achieved by having no code in case (see case 0 and 1): switch (/*...*/) { case 0: // shares the exact same code as case 2 case 1:// shares the exact same code as case 2 case 2: // do something else break; default: // do something entirely different break;} Both case 0 and 1 will execute code of case 2. Using special goto case in switch statement - switch (/*...*/) { case 0: //do something break; case 1: //do something break; case 2: if(condition1) goto case 1; else goto case 2; break; default: // do somethin
Learn Tips and tricks, Concepts, Ideas for software development