I set a similar question a few weeks ago but I cannot still dissolve the ambiguity and the confusion on java operators precedence. This time I have this fragment of code:
int mask = 0;
int count = 0;
if( ((5<7) || (++count < 10)) | mask++ < 10 )
mask = mask + 1;
System.out.println(mask + " " + count);
The result is (unexpectedly to me): 2 0.
Moreover, the compiler provides a warning underlining only the expression (++count<10): dead code.
I reckon however the execution of the code though as either one of the following ways:
1) | has a higher precedence than ||, hence it is considered as there were parenthesis around the expression ( (++count<10) | mask++ <10). This way the compiler should have executed the both parts and count should have been set to 1 (++count<10).
2) If the compiler looks first the (5<7) and after evaluating it to false skips the entire second expression, then mask should not have been increased and we would wait the value 1 in the output.
What have I misunderstood and cannot explain the behavior of the compiler, as well as the output?