Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Nov 18th, 2004, 8:28 AM   #1
thenewkid
Programmer
 
Join Date: Sep 2004
Location: New Jersey
Posts: 36
Rep Power: 0 thenewkid is on a distinguished road
Send a message via AIM to thenewkid
whats upppp!!!im new to java, actually i just started to learn it....i just need to know if it is allowed to use if-else statement within the while statement...and i need to know if i can use Boolean operators within while statement's condition?????THANX!!![color=blue]
thenewkid is offline   Reply With Quote
Old Nov 18th, 2004, 9:41 AM   #2
Eggbert
Professional Programmer
 
Eggbert's Avatar
 
Join Date: Nov 2004
Posts: 250
Rep Power: 4 Eggbert is on a distinguished road
Yes, and yes. Though wouldn't it be faster to test your assumptions with a simple program to see if they work?
Eggbert is offline   Reply With Quote
Old Nov 18th, 2004, 6:39 PM   #3
Infinite Recursion
Programming Guru
 
Infinite Recursion's Avatar
 
Join Date: Jul 2004
Location: United States
Posts: 3,467
Rep Power: 8 Infinite Recursion is on a distinguished road
Send a message via MSN to Infinite Recursion Send a message via Yahoo to Infinite Recursion
Of course... those are permitted in any language... as well as a while loop, with nested loops 10 deep, inside of a while loop that is inside of a while loop, with condition checking throughout.
__________________
http://jasonpowers.net

"There are a thousand hacking at the branches of evil to one who is striking at the root."
Infinite Recursion is offline   Reply With Quote
Old Nov 19th, 2004, 12:34 AM   #4
bl00dninja
Programming Guru
 
bl00dninja's Avatar
 
Join Date: Oct 2004
Location: namespace std
Posts: 1,246
Rep Power: 5 bl00dninja is on a distinguished road
this is a very useful technique called a "sentinel-controlled loop"

psuedo:

boolean sentVal = false
while(sentVal != true)
{
do some things;
some of the things (like a user choice) may want you to quit the loop;
so whenever that (IF) situation comes up;
sentVal = true; //BAM! out of the loop
}

the above "user quitting" scenario is a good example and works great with a do-while loop so the program runs once and then asks if they want to do it again.

:ph34r:
__________________
i put on my robe and wizard hat...

Have you ever heard of Plato, Aristotle, Socrates?...Morons.
bl00dninja is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 4:15 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC