| Author |
for loop
|
Himalay Majumdar
Ranch Hand
Joined: Sep 28, 2008
Posts: 324
|
|
Barring a forced exit, evaluatiing the iteration expression and then evaluating the conditional expression are always the last two things that happen in for loop--K&B
It also says "iterator expression" in for loop doesnt mean just an "increment expression" and so we can write this.
From the above doesn't it mean that "Hello" should be printed twice. Once before executing the body and once after the loop body executes.
|
SCJP 1.6, SCWCD 5.0, SCBCD 5.0 [loading..]
|
 |
Henry Wong
author
Sheriff
Joined: Sep 28, 2004
Posts: 16695
|
|
From the above doesn't it mean that "Hello" should be printed twice. Once before executing the body and once after the loop body executes.
Question. If the code was this instead...
Does it mean that the variable i will be incremented twice? Once before executing the body and once after the loop body exiecutes?
Henry
|
Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
|
 |
Punit Singh
Ranch Hand
Joined: Oct 16, 2008
Posts: 952
|
|
|
No, only after executing the body.
|
SCJP 6
|
 |
Himalay Majumdar
Ranch Hand
Joined: Sep 28, 2008
Posts: 324
|
|
Sorry. I missed that point. Thank you both
|
 |
 |
|
|
subject: for loop
|
|
|