I think this happens because && and || are "short circuit" operators, so the JVM takes the path that will allow it to resolve the expression the fastest. The reasoning may sound a little backwards, but I'll do my best to keep it straightforward:
JVM sees (a = true) || (b = true) && (c = true)
JVM recognizes && has higher precedence, so re-groups expression like this: (a = true) || ( (b = true) && (c = true) )
JVM realizes that if first operand (a = true) is true it can skip everything else, so it checks that first. It turns out that it
is true, so JVM skips the evaluation of the remaining operands since (as far JVM is concerned) they would have no impact on the outcome and evaluating them would be a waste of cycles.
So for short-circuit operators the precedence of && means that ((b = true) && (c = true)) will be evaluated as the right-side operand of the ||
if it is needed to determine the outcome, not
first.
In the same vein, if you had the following code:
The final values would be
a: false
b: false
c: false
Even though
the parenthesis on the right side have higher precedence than && their contents won't be evaluated because they don't need to be.
I hope that helps, but if you'd like me to clarify something I said here (or if I got something dead wrong!) please let me know