outer inner loop

package com.vaannila.student;

public class MyFor{
    public static void main(String argv[]){
        int i;
        int j;
        for (i=1;i <3;i++)
    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
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.
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
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.
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.