I'm a little confused with the above. The output is "1". The first statement, does it read "true or false", which results in a true, then "true and true" gives the first expression true which prints out "1".
So does it means it always works from left to right, given that there's no parenthesis?
But in the example I gave,~ has higher precedance than increment operators,but still it executed last.WHY?
I think the reason is what I found in the JLS,
The Java programming language guarantees that every operand of an operator ( except the conditional operators &&, ||, and ? : ) appears to be fully evaluated before any part of the operation itself is performed.
If the binary operator is an integer division / or integer remainder %, then its execution may raise an ArithmeticException, but this exception is thrown only after both operands of the binary operator have been evaluated and only if these evaluations completed normally.
Also note that, postfix operator(expr++) has higher precedence than (~expr)
For further detail please follow this link [ September 12, 2007: Message edited by: Al Mamun ]