Location>code7788 >text

Summer Java self-study progress summary 05

Popularity:697 ℃/2024-08-09 22:28:17
I. What we learned today:
The first expression of the
if (relational expression) {
Statements;
}
Execute the process:
1> First execute the value of the relational expression
2> if the value of the relational expression is true then the statement is executed, otherwise it is not executed
3> Continue with the rest of the statements that follow
Note: 1> the first curly bracket after the if statement can be on a separate line or can follow (it is recommended that it follow)
2> if the if statement contains only one statement, the curly braces can be omitted (it is recommended to add them when writing your own)
3> For Boolean type relational expressions do not use the "==" sign, directly write the variable name can be
The second expression of
if(relational expression){
Statement 1;
}else{
Statement 2;
}
Execute the process:
1> First execute the relational expression
2> If the value of the expression is true then execute statement 1
3> If the value of the expression is false then execute statement 2
4> Continue with the following statements
The third expression of the
if (relational expression 1) {
Statement 1;
}else (relational expression 2) {
Statement 2;
}
...
else{
Statement n+1;
}
Execute the process:
1> First execute the relational expression 1
2> if true then statement 1 is executed, if false then relational expression 2 is executed
3> if relational expression 2 is true then statement 2 is executed, if it is false then the next relational expression is executed
4>If the first n+1 relational expressions are all false then execute statement n+1
5> Continue with the following statements
The fourth expression of the
switch (expression) {
case value 1:
Statement 1;
break;
case value 2:
Statement 2;
break;
...
default:
Statement n+1;
break;
}
Execute the process:
1> First execute the value in the expression
2> from top to bottom in order to compare the value of the expression with the value of the case has been, consistent with the implementation of the case under the statement
3> Encounter breaks to stop comparison
4> If the value of all cases is inconsistent with the value of the expression then execute the statement after the default