I had to understand some code which mixes pre- and post-increments in functions. There was one thing that confused me.
So I tried to test some smaller function. But I could not explain following behaviour:
int i = 1; i = i++ * ++i * 2; System.out.println("i = " + i); int x = 1; x = ++x * x++ * 2; System.out.println("x = " + x);
The expected output was:
i = 8 x = 8
But actually is:
i = 6 x = 8
Can someone tell me why?