@Java
Loop structure module summary
Hello everyone, I'm Ziph!
Share content knowledge structures under cyclic today.
Mind mapping study in conjunction with better results! Click on the link below to enter the
Java looping constructs mind map (Ziph)
First, the concept of recycling
Concept: a certain condition by repeating the code execution logic section
Two, while circulation
grammar:
while(布尔表达式) {
//逻辑代码(循环操作)
}
Implementation process:
- Boolean expressions first determination result is true, the code execution logic
- After the execution is completed, judgment is performed again, the result is still true, the logic code is executed again
- Results until the Boolean expression is false, will exit the loop structure, subsequent code execution
Circulating composition (part four):
- Initial parts: determination of variables to
- Cycling conditions: deciding whether to cycle basis
- Operation cycle: single logic code or task execution
- Iteration: Control cycle conditions change increment
Features: The first condition that is the entrance, the first judge, and then perform for the number of cycles a clear case
Three, do while loop
grammar:
do {
逻辑代码(循环操作)
} while(布尔表达式);
Implementation process:
- After the first time through the loop operation is performed to determine the Boolean expression
- If the result is true, the execution cycle operation again
- If the result is false, the result will exit the loop, subsequent code execution
Features: no entry conditions for the first time, execute, and then judge, the number of cycles used in ambiguous situations
Four, for circulation
grammar:
for(初始部分;循环部分;迭代部分) {
//循环操作
}
Implementation process:
- For the first time to perform the initial part (only once)
- Boolean expressions determination result is true, the code execution logic
- After this is finished, performs an iterative portion determination again, the result is still true, the logic code is executed again
- Results until the Boolean expression is false, the result will exit the loop, perform subsequent logic code
Features: The first condition that is the entrance to absorb judgments, and then executed for the number of cycles a clear case
Fifth, process control
break;
- Termination, Switch out, the cyclic structure
- Loop is executed, the encounter break ;, exit the entire loop structure
continue;
- The end of this, to enter the next cycle
- Cycle execution, encounters continue, then skip the next to enter the next cycle
Sixth, nested loops
Concept: In a complete cycle structure, the nested structure of another complete cycle
Note: the outer control loop number, the control unit cycles and inner
Do not understand the knowledge of nested loops can click on the link below
to print a variety of triangles, diamonds (Ziph)
print multiplication table (Ziph)
the number of prints daffodils (Ziph)
Using the above links are a classic case of nested loops to achieve.
For questions, please leave a message reply!