I'm confused about a table showing operator precedence. The table is found in this CodeGym article
Why does
expr++
have more precedence than ++expr
? I thought that ++expr
increments first and foremost, whereas expr++
updates its value AFTER being used in the operation. Does anyone understand this?
For instance:
int a = 2;
int b = 3;
int c = ++a + b--;
System.out.println(c); // c prints 6
System.out.println(b); // b prints 2
System.out.println(a); // a prints 3
If postfix (expr++
) has the highest precedence, as shown in the table, then why does the expression ++a
(which has lower precedence) increment the value first? If the postfix expression b--
has the maximum precedence, then why does the value of b
increment after the operation has taken place?