Best way to break out of nested loops

Pages: 12
Feb 13, 2015 at 6:37pm
I'm assuming in code like this:
1
2
3
4
5
6
while (condition A) {
    while (condition B) {
        break while;
    }
    // ...
}

Java will break out of the innermost matching structure (in this case, the nested while loop) and there's no easy way to break out of an outer one when an inner one matches?
Feb 13, 2015 at 8:20pm
It works like that:
1
2
3
4
5
6
7
outer:
while (condition A) {
    while (condition B) {
        break outer;
    }
    // ...
}
Feb 13, 2015 at 10:01pm
Yes, MiiNiPaa shows the correct syntax used by Java.
Topic archived. No new replies allowed.
Pages: 12