Question:

Appearing for scjp 1.5!I have a problem with this code!!Can u help me out?As if u r explaining it to a beginer

by  |  earlier

0 LIKES UnLike

//I am getting truly confused with this code,Can't understand the //purpose of continue outer(it's so confusing,giving a pain in the head) //pls explain the complete code as u r xplaining it to a begineer!! //Looking for a nice reply, who needs 10 points!!

class ContinueLabel {

public static void main(String args[]) {

outer: for (int i=0; i<10; i ) {

for(int j=0; j<10; j ) {

if(j > i) {

System.out.println();

continue outer;

}

System.out.print(" " (i * j));

}

}

System.out.println();

}

}

 Tags:

   Report

2 ANSWERS


  1. There is a label named &quot;outer&quot; on the 3rd line.

    &quot;continue outer&quot; will simply transfer flow back to this label rather than continuing with the inner loop [ for(int j=0; j&lt;10; j ) ]

    This is basically just a check to make sure values stay within predefined parameters. However, this code could have been written without the continue statement.


  2. This will run in an indefinite loop as both loop counters i and j are not getting incremented. Syntactically continue outer is not wrong. but as logic says control will not enter in if condition. Revert if you have doubts

Question Stats

Latest activity: earlier.
This question has 2 answers.

BECOME A GUIDE

Share your knowledge and help people by answering questions.