Meaningless Drivel is fun!*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Labelled and Unlabelled controls?? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Labelled and Unlabelled controls??" Watch "Labelled and Unlabelled controls??" New topic
Author

Labelled and Unlabelled controls??

Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9243
    
    1

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: 9243
    
    1

Thanks Bu.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Labelled and Unlabelled controls??
 
Similar Threads
Labelled and Unlabelled doubt again?
IS-A and HAS-A Relationship Doubts
pls consider this program i don't know how h value is incremented in Label1:
Label control doubt??
what is the diffrence b/W i and i++ and explain inner loops with conditions