Search code examples
javaboolean-expression

Would Java interpret this boolean expression in the way I wanted it to?


This is what I want: !A || (A && B && C) Is this equivalent to the original? !A || A && B && C why or why not?


Solution

  • Yes, they are the same. So is the simplified !A || B && C.

    The && operator has higher precedence than the || operator, so the parentheses around the && operation are unnecessary.