This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes do-while loop in real time Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "do-while loop in real time" Watch "do-while loop in real time" New topic
Author

do-while loop in real time

Harikrishna Gorrepati
Ranch Hand

Joined: Sep 23, 2010
Posts: 422
Hi, Do we ever use do-while loop in real time applications ? In what scenario, we can use this do-while loop (I am not looking for do-while loop purpose/use/meaning)


OCPJP 6.0-81% | Preparing for OCWCD
http://www.certpal.com/blogs/cert-articles | http://sites.google.com/site/mostlyjava/scwcd |
Jelle Klap
Bartender

Joined: Mar 10, 2008
Posts: 1794
    
    7

I'm guessing you mean real-life as opposed to real-time?
If so, then yes, certainly - whenever you need the body of the loop to be executed at least once.


Build a man a fire, and he'll be warm for a day. Set a man on fire, and he'll be warm for the rest of his life.
Harikrishna Gorrepati
Ranch Hand

Joined: Sep 23, 2010
Posts: 422
Hi Jelle, Real Time/Real Life applications refers to same context i.e., In the real project. I knew the answer i.e., "you need the body of the loop to be executed at least once. ". As stated in the question, I am not looking for do-while loop purpose/use/meaning. In what scenario(I am looking for some meaningful example/case)(why should we go for this loop only) , we can use this do-while loop. I hope this reply is not rude. If so, Sorry
ujjawal rohra
Ranch Hand

Joined: Mar 20, 2010
Posts: 105
Hi Harikrishna ,

The answer to your question lies in its use only.
Sometimes in real time applications, we want to execute a piece of code once and on the basis of that execution we decide whether to execute
that code repeatedly or not. For this purpose you cannot use while or for loops; only do-while is suitable.

Hope this will help


SCJP 6
Harikrishna Gorrepati
Ranch Hand

Joined: Sep 23, 2010
Posts: 422
Thanks Ujjawal. I am happy with your reply that has we want to execute a piece of code once and on the basis of that execution we decide whether to execute
that code repeatedly or no
t
ujjawal rohra
Ranch Hand

Joined: Mar 20, 2010
Posts: 105
My pleasure HariKrishna and sorry for a late reply
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: do-while loop in real time