I\'m trying to get deeper with post and pre incrementors but am a bit stuck with the following expression :
public static void main(String[] args) {
int i
Ok, let's break down every thing:
int i = 0; // i = 0, no big deal
Then starting into the most inner parenthesis:
(i+=2 + --i)
i and use the result (-1)-1+2=1)0+1=1=i)At the end, the first decrement is ignored by the reassignation.
Next parenthesis:
i+= (++i + previous_result - ++i)
i ( with ++i) at two points(i+1) + previous_result - (i+2) (notice how the increment are not simultaneous) that gives 2 + 1 - 3 = 0.i (0)Again the increment will get discard by the reassignation.
finally:
i = previous_result
Which gives 0 :)