| Author |
Strange behaviour of "=" and "++"
|
Omer Haderi
Ranch Hand
Joined: Sep 27, 2006
Posts: 42
|
|
When I saw this snippet I was totally sure that the output was: 0 1 But it is: 0 0 if we remove line #2 then it will print zeros for ever. I know that "=" has higher precedence so in line #1 the assignment take place first (so i = 0) and then the post increment (so i becomes 1) but the output is zero does anyone have any hint ? cheers,
|
 |
Chandra Bhatt
Ranch Hand
Joined: Feb 28, 2007
Posts: 1707
|
|
Try this link of this forum: discussed before Got it??? Regards, cmbhatt
|
cmbhatt
|
 |
Barry Gaunt
Ranch Hand
Joined: Aug 03, 2002
Posts: 7729
|
|
|
Search this forum for "i=i++" and you will find over a thousand topics discussing the same problem. Your answer is to be found there.
|
Ask a Meaningful Question and HowToAskQuestionsOnJavaRanch
Getting someone to think and try something out is much more useful than just telling them the answer.
|
 |
Omer Haderi
Ranch Hand
Joined: Sep 27, 2006
Posts: 42
|
|
|
Thanks.
|
 |
 |
|
|
subject: Strange behaviour of "=" and "++"
|
|
|