Hi,
I have a question regarding Dan's exam on Flow control :
class JMM120 {
public static void main (
String args[]) {
int i = 0, j = 0, k = 0;
label1:
for (;

{ i++;
label2:
do {
k = i + j;
switch (k) {
case 0: continue label2;
case 1: continue label1;
case 2: break;
case 3: break label2;
case 4: break label1;
default: break label1;
}
} while (++j<5);
}
System.out.println(i + "," + j);
}}
if i put a
System.out.print("("+i+","+j+","+k+")");
just before the switch statement, it prints the following :
(1,0,1)(2,0,2)(2,1,3)(3,1,4)3,1
But when I try to do it manually, I get :
(1,0,1) , (2,1,3), (2,2,4), (3,3,6)
I think there is difference when j is incremented at
while (++j<5);
Shouldn't be always incremented irrespective of whether we have
break label1/2 or a continue label1/2/
Can anyone please explain me this .
Thanks,
Gayatri