Why did break statement not going to the Inner loop by specifying the label Inner in the following code?. class forloop { public static void main (String args[]) { //int j,k; Outer: for(int i=0; i < 2; i++) { System.out.println("i out "+i); Inner:for(int j=0; j < 3; j++) { if (i==j) { break Inner; //Does not go to the Inner label and increments j } System.out.println("i is " +i +" j is " +j); } } } } Thanks, Iyer.
Break statement would try to break out of the enclosing loop while continue statement would try to continue the enclosing loop with the next loop-variable value -- if your intention is to continue the loop, use continue <label> instead. Hope this helps. - Shankar.