Java operator precendece confusion && and ++

Viewed 398

&& is a short-circuit operator evaluated from left to right, so if the operand on the left side of && operator is evaluated to false, evaluation should not continue. BUT I expected that the ++ should be evaluated before && because it has higher precedence, and (from the link):

Operators with higher precedence are evaluated before operators with relatively lower precedence.

In that case, why doesn't count increment in the third line of this code?

int mask = 2;
int count = 0;
if( !(mask > 1) && ++count > 1) { mask += 100; }
System.out.println(mask + " " + count);
5 Answers
Related