| Author |
Labelled and Unlabelled controls??
|
Joe Harry
Ranch Hand
Joined: Sep 26, 2006
Posts: 8795
|
|
Hi Guys, Consider the code below from Dan Chisholm, Can anyone explain the flow?? Thanks in advance. [ December 07, 2006: Message edited by: Jothi Shankar Kumar Sankararaj ] [ December 07, 2006: Message edited by: Jothi Shankar Kumar Sankararaj ]
|
SCJP 1.4, SCWCD 1.4 - Hints for you, SCBCD Hints - Demnachst, SCDJWS - Auch Demnachst
Did a rm -R / to find out that I lost my entire Linux installation!
|
 |
Burkhard Hassel
Ranch Hand
Joined: Aug 25, 2006
Posts: 1274
|
|
Hi Jothi, perhaps put this line immediately over the switch line: System.out.printf("i:%d j:%d k:%d%n",i,j,k); I don't show the flow, only where the breaks and continues jump to. case 0: continue label2; does not occur (but would jump in between the } and the while). case 1: continue label1; jumps to the third argument of the for loop (after the second semikolon). case 2: break; jumps after the } of the switch block. From there to the while (j gets incremented). case 3: break label2; jumps after the do block, i.e. after the while condition (so j is not incremented). The while condition belongs to the do block! case 4: break label1; jumps after the } of the for loop - System.out. default does not occur. Output with the additional line is i:1 j:0 k:1 i:2 j:0 k:2 i:2 j:1 k:3 i:3 j:1 k:4 3,1 Yours, Bu.
|
all events occur in real time
|
 |
Joe Harry
Ranch Hand
Joined: Sep 26, 2006
Posts: 8795
|
|
|
Thanks Bu.
|
 |
 |
|
|
subject: Labelled and Unlabelled controls??
|
|
|