This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Dans Questions : logic Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Dans Questions : logic" Watch "Dans Questions : logic" New topic
Author

Dans Questions : logic

Kristof Camelbeke
Ranch Hand

Joined: Nov 28, 2001
Posts: 97

Answer : prints 61433
I've tested this prog. and indeed it prints 61433 ; I just don't know why he prints the last 3 because at that time x=3 and the loop should stop, no ?
Stupid question but I just don't get it...
Vicken Karaoghlanian
Ranch Hand

Joined: Jul 21, 2003
Posts: 522
Kristof, the first time it prints 3 the value of success is 1, the second iteration the (x != 3) returns false however (success < 2) return true, which allows one more iteration of the loop, thus printing 3 and then exiting.
Hope this helps.


- Do not try and bend the spoon. That's impossible. Instead, only try to realize the truth. - What truth? - That there is no spoon!!!
Kristof Camelbeke
Ranch Hand

Joined: Nov 28, 2001
Posts: 97
Yes... I guess I was blind for a moment
thanx !
 
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
 
subject: Dans Questions : logic
 
It's not a secret anymore!