I don't understand why this evaluates to true. Do the "|" and "^" have the same level of precedence? I think the answer is yes. So if the order of precedence is the same, then the expression is evaluated left to right? So the statement is equivalenet to
boolean val = (true | false) ^ true;
Which should evaluate to false. I don't understand why the false ^ true portion of the expression is evaluated before the true | portion of the expression.
Can someone please clarify what I am misunderstanding in this expression?
Thank you! That is a good table. It is different from the table I am looking at in OCA Study Guide by Jeanne Boyarsky and Scott Selikoff on page 53. I have not found any errors in this book so I must be misunderstanding their table.
When it says "If two operators have the same level of precedence, then Java guarantees left-to-right evaluation" I interpreted that to mean that the expression would be evaluated left to right. Maybe what is meant is that the precedence of the operators in the table should be ordered left to right? That seems very very confusing to me.