I. Usage and attention of switch statements
Switch (expression)
{
Case: ' * * * ';
Break
Case: ' &&&;
Break
.
.
.
Default
}
The control expression type in a switch statement can only be byte, short, char, and int cannot be a string.
The switch statement first evaluates expression expression, then compares the expression with the value of the case label, once the value of the star is encountered, the program starts executing the case tag code, no longer the case after the fragment, the default label condition matches, It will not end until a break is encountered.
Second, for Loop
A For loop is a more concise loop statement
For (initialize: loop condition : loop body) When the program executes a for loop, the initialization statement for the loop is executed first, and the initialization statement executes only once before the loop starts. Each time the loop body is executed, the value of the loop condition is evaluated, and if the loop condition returns True, the loop body part is executed, and after the loop body execution finishes, the iteration statement is executed. Therefore, for a for loop, the loop condition is always executed more than the loop body, because the last execution of the loop condition returns false, and the loop body is no longer executed.
Learning Note 5