What we learn today is the statement structure: sequence, branch, and loop structures.
These structures are not detailed, and we often use them in daily learning. Below are some knowledge points that are easier to test.
1. problems that may occur during the switch interview:
Int I = 4;
Switch (I ){
Default: system. Out... println ("not clear ");
Case 1: system. Out. println ("I = 1"); break;
Case 2: system. Out. println ("I = 2 ");
}
First, this will match the content of the case section. If the result does not match, the default statement will be executed. After the default statement is executed, case1 will continue to be executed. The result of case1 is output, and the break will jump out of the switch.
2. Difference Between while and do while
1) The do while statement first executes the loop body and then judges the condition, that is, it must be executed at least once no matter whether the condition is met or not.
2) while first judge the condition, as long as the condition does not meet the execution;
3. What is the difference between break and continue?
1) break ends the current loop
2) Continue jumps out of the current loop and continues the next loop
3) Labels allow break and continue to work and specify a range, for example, the following break example
Label1: (;;){
For (;;){
Break label1; // The layer loop corresponding to label1.
}
}
It is relatively simple to write. You are welcome to comment on my notes!