Break in the WHILE circuit inside FOR LOOP
2 answers
use label and break
here:
while (...) {
for (...) {
if (...) break here;
}
}
see https://docs.oracle.com/javase/tutorial/java/nutsandbolts/branch.html
+3
source to share
Want to get out of all cycles
You can use simple break;
to end an immediate containing loop, and in Java you can use labeled
break to end an arbitrary loop. how
out: for(;;) {
while(true) {
while (true) {
// ....
break out;
}
}
}
The label is the text before :
(and the word after break
in the above example).
Note . The unlabeled break statement terminates the innermost switch, for, while, or do-while, but the unlabeled break terminates the outermost statement .
+3
source to share