Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

The tricky for-loop

 
Tommaso Nuccio
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Tommaso Nuccio
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dang,



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

Thank you.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic