my dog learned polymorphism*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes  do while loop Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark " do while loop" Watch " do while loop" New topic
Author

do while loop

M Srilatha
Ranch Hand

Joined: Aug 27, 2008
Posts: 137
Hi,

Could any one please explain me how the following code works?




I thought the code will not compile! But it compiles as well as runs


Thanks,<br />Srilatha M
Himanshu Gupta
Ranch Hand

Joined: Aug 18, 2008
Posts: 598

why you thought that this code will not compile? it looks OK. no problem in the code.


My Blog SCJP 5 SCWCD 5
M Srilatha
Ranch Hand

Joined: Aug 27, 2008
Posts: 137
Hey thanks for the reply!

I got it now.
This is how it works!


Before i was thinking that line 4 is a do while loop where its actually do in line4 pairs up with while in line 06. I didnt think in that way.

Anyways now its clear!
Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9293
    
  17

I think there will be no output.

The code can be thought of as



SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
 
jQuery in Action, 2nd edition
 
subject: do while loop