Breaking out of nested loops in Java

If you have a nested loop in java and need to terminate it you can put a label on the other loop to use on the break statement. Without the label, it will break out of the inner loop but will continue in the outer (and enter inner again). The example below shows how this is done:

The output from the code above is this:

Search for more Java info on this site here:
Custom Search

Please type any questions here.