I have this question regarding priorities. Java states that this is the priority to work out operators (from high to low):
Now, if you look at unary operators, they state that:
In the unary postfixnotation , unary gets executed after the expression.
Meaning that if you have:
int a = 2;
int b = a++ * 3;
int b
will be 6, cause a only gets +1 after the expression.
in the unary prefixnotation, unary gets executed before the expression:
int a = 2;
int b = ++a * 3;
int b
will be 9.
My question is, doesnt this mean that postfix unary operators should be at number 6 and prefix at number 1? What am I seeing wrong?
The "expression" that the unary operator is applied after the evaluation of is a
, not any expression it might be part of.