Debugging
Step 1: Set a breakpoint (you cannot set a breakpoint in an empty space)
Step 2: Start debugging
Step 3: Debug the Code (F6 single-step skip)
Notebook Fn+f6 (F5)
Step 4: End Debugging
Mastering the benefits of debugging?
1. Clearly see the order in which the code executes
2. Quickly navigate to where the exception code appears and help modify or improve the code
Second, while loop
1, the advantages of the cycle?
Reduce duplication of code writing
The program will be more concise
2. Grammar
while (expression) {//1, the expression is a "loop condition", the result must be code in Boolean type//2, {}, "loop operation (body)"//3, "Iteration part" change loop condition, end loop}
3, Characteristics: First judge, then execute
4. While loop has 2 common ways
Mode 1:
while (1, loop condition determines whether strings are equal) {
2, loop operation//3, receive the string in the keyboard again, change the loop condition, to end the loop
}
Mode 2:
while (1, the loop condition int variable is compared with the relational operator) {
2. Cyclic operation
3, iteration part, int variable + + or--, to change the loop condition, end the loop operation
}
Third, Do....while cycle
1, applicable occasions: first cycle 1 times, according to the conditions of judgment, recycling
2. Grammar
do{
2. Circulating body (cyclic operation)
3, change the circulation condition}while (condition); 1. Cyclic conditions
Iv. use cases for the For loop
While loop--first judge, then loop
while (1, conditional expression) {
2. Cyclic operation
3. Change the Loop condition expression
}
do...while--first cycle, then judge
do{
2. Cyclic operation
3. Change 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
V. Syntax for a FOR loop
for (1. Initial part; 2. Condition judgment; 3. Iteration section) {
4. Cyclic operation
}
Vi. execution order of the For loop
1th Cycle
Perform the initial part first (only when the 1th loop is executed)
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
2~n 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
Seven, 2 keywords
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
Continue
In the loop, end the loop and go to the next loop.
Java Fundamentals 4