Through Java operator precedence table:
'|' Logical OR operator has higher precedence than '&&' logical AND operator.
I checked above fact using following code
int y = 5; int x = 2; if( x++ > 2 && ++y > 2 | true ) ; //do nothing System.out.println("x = " + x + " y = " + y); but above line giving output as -
x = 3 y = 5 showing that x++ is evaluating first.
Even I put parentheses at condition around |
if( x++ > 2 && (++y > 2 | true) ) ; But still I am getting the same output.
Why operator precedence not working in this case?