Breaking loop iteration using Continue statement in java

Using Continue statement in java to break loop iteration

The Continue statement is used to break the current iteration of the loop (for, while, do while) wihtout executing the rest of the code after the continue and skip the next one.

if no label is specified the continue escape to the nearest loop

public class ContinueMain {

    public static void main(String[] args){
        // Creating a LABEL
        GLOBAL_LOOP: for (int i=0 ; i<3 ; i++){
            for (int j=1; j<=10 ; j++){
                if (j % 5 == 0) {
                    System.out.println("continue to the loop with the label GLOBAL_LOOP");
                    // Continue to label
                    continue GLOBAL_LOOP;
                }
                if(j%2==0){
                    System.out.println("continue to the nearest loop");
                    // Continue to the nearest loop
                    continue;
                }
                System.out.println("i: " + i + " j:" + j);
            }
        }
    }
}
//i: 0 j:1
//continue to the nearest loop
//i: 0 j:3
//continue to the nearest loop
//continue to the loop with the label GLOBAL_LOOP
//i: 1 j:1
//continue to the nearest loop
//i: 1 j:3
//continue to the nearest loop
//continue to the loop with the label GLOBAL_LOOP
//i: 2 j:1
//continue to the nearest loop
//i: 2 j:3
//continue to the nearest loop
//continue to the loop with the label GLOBAL_LOOP