int it=9, at=9;
if(it>4 || ++at>10 && it>0)
{
System.out.print(\"stuff\");
}
System.out.print(at);
prints out stuff9 a
Your compound expression is equivalent to
if(it>4 || (++at>10 && it>0))
due to Java operator precedence rules. The operands of ||
are evaluated left to right, so it>4
is evaluated first, which is true
, so the rest of it (the entire &&
subexpression) doesn't need to be evaluated at all (and so at
does not change).