Explain Switch statement

Switch statement: It is a selection statement in which the value of an arithmetic expression {expression!arithmetic} is compared for the match alongside different case labels. When no match is found, the optional default label is chosen For example:

    switch(choice){
         case 'q':
             quit();
             break;
         case 'h':
             help();
             break;
         ...
         default:
             System.out.println("Unknown command: "+choice);
             break;
    }

   Related Questions in Programming Languages

©TutorsGlobe All rights reserved 2022-2023.