outer inner loop

package com.vaannila.student;

public class MyFor{
    public static void main(String argv[]){
        int i;
        int j;
    outer:
        for (i=1;i <3;i++)
        inner:
    for(j=1; j<3; j++) {
        if (j==2)
        continue outer;
        System.out.println("Value for i=" + i + " Value for j=" +j);
    }
    }
}


I was trying above example from link
http://www.jchq.net/certkey/0202certkey.htm
got output like


Value for i=1 Value for j=1
Value for i=2 Value for j=1




I was trying to understand the output. Any links, ideas, resources,sample code highly appreciated. thanks in advance.
LVL 7
gudii9Asked:
Who is Participating?
 
for_yanConnect With a Mentor Commented:
break outer; - goes immediately out of
the loop over which you have label "outer"

continue outer; skips the rest activity until
the point when you need to go the next run
of the loop above which you placed  label outer
0
 
for_yanCommented:
This seems to make sense

When i=1 it goes till j= 2 but when j=2 it does not
print already but jumps to the next pass of
outer loop - i becomes 2 and aagian it prints when j=1
but jumps to the outer when j=2
but at this point i becomes 3 and it goes aawya altogether.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.