Rubbal Bhusri wrote:
R. Jain wrote:See UseCodeTags
This question have been asked numerous times..
Check thisFAQ for your doubt..
The link you shown doesn't tell exactly about the behavior in arrays otherwise that I already know as I also gave an e.g. of simple execution of post-increment operator .
I want to know the behavior in arrays , the code I wrote on an array .
Could you please explain about that ???
It doesn't make any difference while working with array..
arr[x++] = 1 assigns 1 to arr[0]..
I gave you that link because the first statement you wrote is quite common understanding amongst all but not correct..
You wrote: -
Rubbal Bhusri wrote:as far as I know about post increment operator, it first uses the value, and then increments the value.
But, in actual, it first increments the value, but before incrementing it stores the value for future use..
Now after it is done with incrementing,uses the value previously stored for assignment..
You see the difference..
So ideally, if you have i = 0 and , if you write : -
i = i++;
You still have i = 0 after this statement, even though you are sure it will be incremented after the semi-colon(;)
This is because the above statement is executed as follows: -
tempVarByJVM = i;
i++;
i = tempVarByJVM;
So, i = 0;