i = i++ + f1(i);
But how can it remember the values of i as 5, while passing the i value as 6 to the method call??....
You need not to remember anything. I told what applies to post increment
operator and such an expression. You may have heard expression evaluation.
First the entire expression is evaluated then operation is done.
i=5; //initially
for this expression
i = i++ + f1(i); where you see i++, value of
i++ is evaluated to be 5, and because it is post increment operator the
value is incremented after it is used in the expression. OK? Now when i has
been used in the expression, i is incremented by 1 resulting 6, that is
passed to the method f1(i);
Take care what was the result of evaluating i in the expression we just did?
Correct! It was 5, so it will be used while addition resulting value 8
(5+3(returned from the method f1(...))).
Got it?
Thanks,