boolean a = true;
boolean b = true;
boolean c = false;
System.out.println(a || b && c); // true
System.out.println(b && c || a); // true
I just recently discovered what I thought was a bit of an oddity here. Why is it that && and || are at different precedence levels? I would have assumed that they were at the same level. The above demonstrates it. both statements are true even though a left to right evaluation would give false for the first and true for the second.
Does anyone know the reasoning behind this?
(BTW, I would have just used a load of parentheses here, but it was old code which brought up the question)