Java Fundamentals (Chapter six)
One, for the use of the cycle of the occasion
L While loop--First judge, recycle
While (1, conditional expression ) {
//2 , cyclic operation
//3 , changing the loop condition expression
}
L do...while--Cycle First, then judge
do{
//2 , cyclic operation
//3 , changing the loop condition expression
}while (1. Conditional Expressions );
The above 2 cycles, generally used in the case of uncertain cycle times
Number of known cycles, preferred for loop
Ii. syntax for A For loop
For (1. Initial Part ; 2. condition judgment ; 3. Iteration Section ) {
4. cyclic operation
}
Iii. order of execution for a For loop
Section 1 Secondary Cycle
L Perform the initial part first ( only executed at 1 cycles )
L re-judge the condition.
N If the condition is met, the loop operation is performed
N If the condition is not met, the loop ends
Section 2~n sub-cycle-condition Satisfaction
After the 1th time the loop operation is completed
Perform the Iteration section first
And then the condition is judged.
If the condition is met, the loop operation is performed
If the condition is not met, the loop ends
Four, 2 keywords
L Break " General and if conditional statements are used together "
To end a switch statement in a switch statement
To end or terminate a loop in a loop structure
L Continue
In the loop, end the loop and go to the next loop.
Java Fundamentals (Chapter six)