Example of continue with a label in Java

start:
for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 4; j++) {
        if (j == 2) {
            continue start;
        }
        System.out.println(i + ":" + j);
    }
}

The result of running this code is as follows:

0:0
0:1
1:0
1:1
2:0
2:1

Enjoyed this post? Share it!

 

Leave a comment

Your email address will not be published.