If of a Java conditional statement
Note: If the IF condition is set when the execution statement is only one, it is possible to omit the curly brace drop! But if there are multiple execution statements, then curly braces are indispensable.
The if...else of the Java conditional statement
The multiple if of a Java conditional statement
Nested if of a Java conditional statement
Switch of the Java conditional statement
Execution procedure: When the value of the expression after switch is the same as the value after the case statement, it starts down from that position until the break statement is encountered or the switch statement block ends, and the code of the default block is executed if there is no matching case statement.
The while of the Java Loop statement
Execution process:
< 1 >, determine if the condition behind the while is established (True/false)
< 2 >, when the condition is established, execute the operation code within the loop, then repeat < 1 >, < 2, until the loop condition is not established
Features: first judgment, after execution
The do...while of the Java Loop statement
Execution process:
<1>, perform the cycle operation first, and then determine if the loop condition is true
<2>, if the conditions are established, continue to implement < 1 >, < 2, until the cycle conditions are not established
Features: First execution, after judgment
Thus, the Do...while statement guarantees that the loop is executed at least once!
The Java Loop statement for
Execution process:
<1>, executes the loop variable initialization section, sets the initial state of the loop, which executes only once in the entire loop
<2>, the judgment of the cyclic condition, if the condition is true, the loop body code is executed, and if False, the loop is exited directly
<3>, execute cyclic variable change part, change the value of the loop variable, in order to make the next condition judgment
<4>, re-execute < 2 >, < 3 >, < 4, until Exit loop
Features: simpler and easier to read than the while and DO...WHILE statement structure
Break of the Java loop jump statement
Use the break statement to exit the specified loop and execute the code immediately following the loop.
The continue of the Java loop jump statement
The function of continue is to skip the remaining statements in the loop body to perform the next loop
java-Process Control Statements