Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

labeled break Statement Java

class LabeledBreak {
    public static void main(String[] args) {
   
        // the for loop is labeled as first   
        first:
        for( int i = 1; i < 5; i++) {

            // the for loop is labeled as second
            second:
            for(int j = 1; j < 3; j ++ ) {
                System.out.println("i = " + i + "; j = " +j);
             
                // the break statement breaks the first for loop
                if ( i == 2)
                    break first;
            }
        }
    }
}
 
PREVIOUS NEXT
Tagged: #labeled #break #Statement #Java
ADD COMMENT
Topic
Name
3+1 =