I know that the following question has been asked several times already but I never encountered a satisfying answer as to why the priority of operators seems to change between following 2 scenario's:
Scenario 1:
int i = 0, j = 0;
j = i++;
System.out.printf("i=%d j=%d \n", i, j); // i=1 j=0
The operation j = i++ evaluates, according to the priority of operators, as follows:
step 1: j = i
step 2: i++
'++' operator AFTER '=' operator The output seems to confirm this. So far so good.
Scenario 2:
int i = 0;
i = i++;
System.out.printf("i=%d \n", i); // i=0 ???
The operation i = i++ evaluates, NOT according to the priority of operators, as follows:
step 1: i++
step 2: i = i
'++' operator BEFORE '=' operator ???
What am I missing here?
regards Chris