A select cycle syntax
select
IF
if (expression)
statement A;
if the value of the expression is true, it will execute the statement A, or is not performed
if (expression) {
statement A;
statement B;
}
If the expression the value is true, it will execute the statement a and statement B, or do not perform
range
if (expression)
statement a;
statement B;
at this time if the expression is true, it will execute the statement a, otherwise it will not execute, and statement B regardless of whether the expression is true, will be implemented, in other words, the statement B will be executed. That is, if only the entry into force of the statement A.
if (expression) {
statement A;
statement B;}
At this time, if the expression is A, will execute the statement A, B statements, or not performed, in other words, IF statements can control statements A and B are simultaneously carried out.
if (expression) {
statements;
} else {
}
If the expression is true, then following the if statement is executed, or the statement that follows else
if and else statements, one of them must be performed
if (Expression 1) {
statement 1;
} else if (Expression 2) {
statements 2;
} else if (Expression 3) {
statement 3;
} ......
else if (expression n) {
statements n-;
} {the else
statement executed is not satisfied
}
program from top to bottom, turn judgment, if the true and false and the following expressions if the else, if not true, else statements are executed
when the program was first discovered when the true expression, its curly braces expression corresponding statements will be executed, else if and else statements behind it will not be executed, even if its expression is true.
Switch
Switch statement syntax:
Switch (expression) {
Case 1 target:
execute statement 1;
BREAK;
Case target 2:
execute statement 2;
BREAK;
......
......
Case target n:
execute statement n-;
BREAK;
default:
execute statement n + 1;
BREAK;
}
program statement case expression target value comparison, if consistent with the corresponding statement is executed, otherwise, the determination at a target value. If not met, the default statement is executed after
two while loop
while (expression) {
statement A;
statement B;
}
if the expression is true, the code braces is executed, and otherwise does
do ...... while
do {
Code
} while (expression)
regardless of whether the expression is true, execute the code again braces, and then determine the truth while in the expression, if true, the loop continues, otherwise, out of the loop.
Three for loop.
Syntax:
program to execute a statement 1, and then determine whether the expression is true, if the expression is true, the corresponding code is executed, and then execute the statement 2, it is determined whether or not satisfy the expression
if the expression is false, out of the loop
for (Statement 1; expression; statement 2)
statement A;
statement B;
scope, only the sentence A force, in other words, only the control statements for loop A
for (statement 1; expression; statement 2) {
statement A;
Statement B;
}
scope, while braces statements A, B statements into effect, in other words, for all the code loop can control whether to perform the braces.
java, if the cycle is determined, and
Guess you like
Origin www.cnblogs.com/zenghongfei/p/11482336.html
Ranking