Control Statement 1.1 sequential structure (most common)
Features: code executes from top to bottom
1.2 Selection structure:
If Judgment statement:
Switch Judgment statement:
Considerations for using the switch statement:
1. A break is required at the end of each statement to prevent the switch from penetrating.
The amount used to judge in a 2.switch statement can only be int, Short,char,byte String (only after Jdk7)
The data followed by 3.Case must be constant.
The advantages of the switch statement: The statement structure is clear, the running rate is fast.
Disadvantages of the switch statement:
If the switch can do not do, switch can do the if must be implemented.
1.3 Cycle Structure
While loop: First judge the execution
Structure:
while (loop condition) {
Loop body.
}
Do and loop: once executed, the loop body is bound to execute once.
Structure:
bo=
Circulation body;
}while (cyclic conditions);
For loop:
Structure:
for (;;) {
Loop body
}
Control statements in Java