How/Can you use both && and || in the same if statement condition?
java, logical-operators, operators
Solution
The operator `&&` has a higher precedence than `||`, so `&&` will be evaluated first.
http://introcs.cs.princeton.edu/java/11precedence/
Still, many programmers will not remember that fact. It is clearer and more maintenance-friendly to use parenthesis to specifically state the order of evaluation intended.
Note that in your code you write
x=y
that is actually the assignment operator, not the equality operator. Presumably you intend
x==y
Problem
Which logical operator get "prioritized" or "read" ahead of the other, so to say. For example: ``` if( x=y || y=y && x=x ){} ``` is java reading this as: One of these two: (x=y||y=y), AND (x=x) or as: Either (x=y) or (y=y AND x=x) Sounds like something that would have been asked or at least easy to find, but alas, "and" + "or" are keywords to Google.