source:
https://coderanch.com/t/263901/java-programmer-SCJP/certification/loops] class JMM121 {
public static void main (
String args[]) {
int h = 0, i = 0, j = 0, k = 0;
label1:
for (;
{
h++;
label2:
do {
i++;
k = h + i + j;
System.out.println("value of j is:"+j);
switch (k) {
default: break label1;
case 1: continue label1;
case 2: break;
case 3: break label2;
case 4: continue label2;
case 5: continue label1;
}
System.out.println("change j:");
} while (++j < 5);
}
System.out.println(h + "," + i + "," + j);
}
}
i got output as:
value of j is:0
change j:
value of j is:1
value of j is:2
1 3 2
when continue label2; is executed the control has to check for while condition for next iteration of do-while loop.
In this case it is not executing System.out.println statement which is placed in between those lines.
why?
Is it jump to check the conditon directly?
[ November 05, 2008: Message edited by: Ganeshkumar cheekati ]
[ November 05, 2008: Message edited by: Ganeshkumar cheekati ]
[ November 05, 2008: Message edited by: Ganeshkumar cheekati ]
[ November 05, 2008: Message edited by: Ganeshkumar cheekati ]
[ November 06, 2008: Message edited by: Jesper Young ]