How to easily break from the inner and outer loop

This how to break from the inner and outer loop.
search:
    for (i = 0; i < arrayOfInts.length; i++) {
        for (j = 0; j < arrayOfInts[i].length; j++) {
            if (arrayOfInts[i][j] == searchfor) {
                foundIt = true;
                break search;
            }
        }
    }

reference:
Refer to: http://java.sun.com/docs/books/tutorial/java/nutsandbolts/branch.html

0 comments:

Post a Comment