break only breaks out of the current loop, which is the inner loop. If you want to break out of the outer loop, there are two ways:
1: for(int i = 0;i<9;i++){ //Use two breaks
for(int j = 0;j<8;j++){
break;
}
break;
}
2: flag: for(int i = 0;i<9;i++){ //Add a mark before the loop to be jumped out, Then you can use break flag at any
//any position in the marked loop; you can jump out of the marked loop
for(int j = 0;j<8;j++){
break flag;
}
}
Break jumps out of the current layer loop, which means that the inner loop of this layer ends and the outer loop continues to be executed; the scope of break is to jump out of the current layer and execute the previous layer loop.
Explanation: break means to jump out of this loop and continue to execute the previous layer, that is, the outer layer. Contiue means to jump out of this loop and continue to execute the inner loop.