This week's giveaway is in the EJB and other Java EE Technologies forum. We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line! See this thread for details.
First of all I believe you're supposed to quote your sources (I believe this is from K&B).
Second the value of x is incremented twice in the for loop IF ++x>2 or ++y>2, once AFTER the "if" condition has executed and then once more after x++ has executed.
So let's look at the results for x, y, and z after each iteration of the for loop.
iteration z x x++ y 1 0 1 (1 not >2) no call 1 2 1 2 (2 not >2) no call 2 3 2 3 (3 is >2) 4 (call) 2 (no change) 4 3 5 (5 is >2) 6 (call) 2 (no change) 5 4 7 (7 is >2) 8 (call) 2 (no change) 6 5 - not less than 5 for loop ends.
I think what you're missing here is that the value of x does NOT get incremented twice for the first 2 iterations because both cases of the if block are not true and therefore x++ is not reached.
sumaraghavi please try to use different and more meaningful subject lines as it may confuse those who want to reply to your posts. For example the following post looked like a double post because you used the same heading