As of my under standing &&
has a higher precedence than ||
given with the following code
static boolean a;
static boolean b;
static boolean c;
public static void main(String[] args) {
boolean d = (a = true) || (b = true) && (c = true);
System.out.println(a + " " + b + " " + c + " ");
}
the output of this code is true false false
, since there are parentheses I assume that the assignment of true
to variables a,b and c will be first executed before the executing the expressions for &&
and ||
which is on my understanding is like (a = true) || ((b = true) && (c = true)) but based on the output it seems that after assigning true
to variable a the left side of ||
has been executed already and thus not execute the rest of the code. Does it mean that ||
has overridden the &&
since the left side has been executed?