In Java, the only place the label works is just before the iteration statement.
"Just before" means that it is not good to place any statements between tags and iterations.
The only reason to set the label before the iteration is that we want to nest another iteration or a switch, because break and continue keywords usually only interrupt the current loop, but if used with the tag, they break the loop until the label is in place
Label1:
outer-iteraction{
inner-itercation{
Break;//1
Continue;//2
Continue LABEL1;//3
Break LABEL1;//4
}
}
In 1, break interrupts the internal iteration, returning to the outer iteration
In 2, continue moves the execution point back to the beginning of the internal iteration
In 3, Contiune Label1 interrupts both internal and external iterations and goes directly to Label1, and then he actually continues the iterative process, but begins with an external iteration
In 4, break Label1 also interrupts all iterations and goes back to Label1, but does not re-enter the iteration, which means that it actually completely aborts two iterations
The role of tags in Java