operator precedence says && is evaluated before ||
In dan 's exams I saw couple questions which had the following code, I am just giving the lines which are relevant.. the code was compilable
...
static boolean a;
static boolean b;
static boolean c;
public static void main(
String args[]){
boolean x = (a=true) || (b=true ) && (c=true);
System.out.println(x + " " + a + " " + b + " " + c);
}
In this case should I be evaluating
((b=true) &&(c=true)) first and then evaluate the result with (a=true)
According to Dan's answers apparently, the precedence order is not relevant here and what happens is that it evaluates a=true and stops right there.
x=true
a=true
b= false
c=false
Can somebody throw light on this?
thanks