wood burning stoves 2.0*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes The tricky for-loop Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "The tricky for-loop" Watch "The tricky for-loop" New topic
Author

The tricky for-loop

Tommaso Nuccio
Ranch Hand

Joined: Dec 11, 2006
Posts: 66
Hi there,

I got this question from javablackbelt.com, John Hunt's exam.
I cannot figure out the point here:


Why does it skip the for loop and prints "Total 0"?

Thanks in advance.


Ciao,<br /> Tommaso<br /> <br />~*~*~*~<br />There are 10 types of people, those who understand binary and those who don't.
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

Originally posted by Tommaso Nuccio:
...Why does it skip the for loop and prints "Total 0"? ...

"total" is set to zero, and the body of the loop will only execute if total is greater than 30.


"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
Tommaso Nuccio
Ranch Hand

Joined: Dec 11, 2006
Posts: 66
Dang,



I read it "until total is greater than 30".

Thank you.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: The tricky for-loop
 
Similar Threads
"For " loop
confused!!!
For loop / variable ?
Please tell me why it prints 0
Doubt in for loop