Breaking loop using Break statement in java

Using Break statement in java to exit a loop

The Break statement is used to terminate the current loop (for, while, do while, switch) wihtout executing the rest of the code after the break.

If no label is specified the break statement terminate the the nearest loop

public class BreakMain {

    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 (i % 2 != 0) {
                    System.out.println("break the loop with the label GLOBAL_LOOP");
                    // Continue to label
                    break GLOBAL_LOOP;
                }
                if(j % 2 == 0){
                    System.out.println("break the nearest loop");
                    //continue to the nearest loop
                    break;
                }
                System.out.println("i: " + i + " j:" + j);
            }
        }
    }
}
//i: 0 j:1
//break the nearest loop
//break the loop with the label GLOBAL_LOOP