+ 1

Break All???

How can i break from multiple nested for loops??

19th Mar 2017, 3:14 PM
Reza
Reza - avatar
2 Antworten
+ 5
outer: for (int a : array) { for (int j : array2) { if (i == j) break outer; } } Create a label before a loop and use this label in break.
19th Mar 2017, 3:43 PM
Tamás Barta
Tamás Barta - avatar
+ 2
You can for example use booleans: loop1 loop2 loop3 if bla bla vartostop = true; if vartostop == true { break; } if vartostop == true{break} if vartostop == true {break}
19th Mar 2017, 3:17 PM
Geoffrey L
Geoffrey L - avatar