If statement
* If statement has three formats
*
* If statement format 1:
* if (relational expression) {
* Statement body;
* }
*
* Execution Order:
* A: Evaluates the value of the relationship expression first, to see if it is true or false
* B: If true, the statement body is executed,
* C: If it is false, do not execute the statement body
*
* Does not affect the execution of other statements
* If statement format 2
* if (relational expression) {
* Statement Body 1
*}else{
* Statement Body 2
* }
*
* Execution Process
* A: Calculate the value of the relationship expression first,
* B: If true, the statement body is executed 1
* C: If False, execute statement body 2
If statement format 3
* if (relational expression) {
* Statement body 1;
*}else if (relational expression 2) {
* Statement body 2;
* }
* ...
* else{
* Statement body n+1;
* }
*
* Execution Order:
* A: First judge the relationship expression 1, true or FALSE,
* B: If true, executes the statement body 1;
* C: If False, continue to determine the relationship expression 2, true or FALSE,
* D: If True, execute the statement body 2, otherwise continue to judge the relationship Expression 3 ...
* E: If the above are false, execute the statement body n+1;
Switch statement format:
* Switch (expression) {
* Case value 1:
* Statement body 1;
* BREAK;
* Case Value 2:
* Statement body 2;
* BREAK;
* ...
* Default:
* Statement body n+1;
* BREAK;
* }
*
* Format Explanation:
* Expression: can be Byte,short,int,char,
* JDK5 can be enumerated later
* JDK7 can be a string later
* The value after case is the content to match the value of the expression
* Break: Just the meaning of the interruption
* Default: When all values do not match, the default is executed
*
* Execution Process:
* A: First the value of the computer expression
* B: Take this calculated value, followed by the value after the case, and once there is a matching execution of the corresponding statement body, in the process of execution encountered a break in the end
* C: If all the case does not match, execute the statement body n+1;
The format of the FOR Loop statement:
* for (initialize statement; Judge conditional statement; Control condition statement) {
* Circular body statement;
* }
*
* Execution Process:
* A: Execution of initialization statements
* B: Execute judgment condition statement to see if the result is true or false
* If False, end the loop
* If true, continue execution
* C: Execute loop Body statement
* D: Execute control condition statement
* E: Go back to B
While loop statement format:
* WHILE (judging conditional statements) {
* Circular body statement;
* }
*
* Extended Format:
* Initialization statement;
* WHILE (judging conditional statements) {
* Circular body statement;
* Control condition statement;
* }
*
* Review the FOR Loop statement:
* for (initialize statement; Judge conditional statement; Control condition statement) {
* Circular body statement;
* }
*
* Summary: While and for can be converted to each other
Do...while Loop Statement Format:
* do{
* Circular body statement;
*}while (Judgment condition statement);
*
* Extended Format:
* Initialization statement;
* do{
* Circular body statement;
* Control condition statement;
*}while (Judgment condition statement);
*
* Execution Process:
* A: Execution of initialization statements
* B: Execute loop Body statement
* C: Execute control condition statement
* D: Execute the JUDGMENT condition statement to see if it is true or false,
* If False, end loop
* If true, go back to B
*/
Although three loops can do the same thing, there is still a difference
* A:do...while Loop performs at least one cycle body
* B:for And while must judge condition to be able to execute loop body
*
*
* The difference between A for loop and a while loop:
* The initialized variable is not available after the For loop, and the initialized variable can still be used after the while loop ends
*
* The order of loops is recommended:
* For---while---do: While
*
* Break: Meaning of the Interruption
*
*
* Usage Scenarios:
* In the A:switch statement
* B: In the Loop
*
Note
* It doesn't make sense to leave the scene
*
Role
* For End Loop
Continue: the continuation means
*
* Usage Scenario: in loop
*
* Note: It doesn't make sense to leave the scene
*
Role
* End a loop to continue the next cycle
*/
Break: End the entire loop
* Continue: End this cycle, continue the next cycle
2018-10-06 Summary