I have the following Java code snippet that returns false when I expect it to return true:
assertTrue(true || false ? false : false);
The statement was discarded for the sake of this message (it was originally used to compare strings), and I know that it can be simplified so as not to use the ternary operator, but basically I'm trying to understand why Java evaluates it like this:
(true || false) ? false : false
instead of this:
true || (false ? false : false)
I expect him to evaluate the truth and come out. Does anyone know why this is not so?
source share