Switch select structure, switch structure
Switch (expression) // expression can use byte, short, int, char {case value 1: logical statement; break; // jump out of switch statement case value 2: logical statement; break; default: // all conditions do not conform to the use of default, which is irrelevant to the location of the default logical statement; break; // The Last One can be omitted}
There are two methods to terminate a switch: 1. Execute a break to jump out of the switch. 2. Execute the switch to the end of the switch statement {}.
If the case in the switch does not have a break statement, the program continues to execute the logical statement without judging the case statement.
Another form of switch
Switch (expression) {case value 1: case value 2: case value 3: logical statement; break; case value 4: case value 5: case value 6: logical statement; break; default: logical statement; break ;}