aspose file tools*
The moose likes Beginning Java and the fly likes I thought I understood this stuff..... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "I thought I understood this stuff....." Watch "I thought I understood this stuff....." New topic
Author

I thought I understood this stuff.....

David Leland
Greenhorn

Joined: Jun 19, 2002
Posts: 11
I was practicing from Dan Chisholm's java tests and came across this question.

Here's my question. During the 3rd loop the variable "x" is set to 3. success is still 0. Shouldn't the loop stop since x is 3??
Any insight would in helpful...
Bosun Bello
Ranch Hand

Joined: Nov 06, 2000
Posts: 1510
The loop will not stop because of this statement.
while ((x != 3) || (success < 2))
You are saying the loop should continue as long as one of the conditions is true.
You need to use &&
while ((x != 3) && (success < 2));


Bosun (SCJP, SCWCD)
So much trouble in the world -- Bob Marley
David Leland
Greenhorn

Joined: Jun 19, 2002
Posts: 11
DOH!
Ok - I guess studying all this stuff is messing with my mind. Thanks for the clarification.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: I thought I understood this stuff.....