Search code examples
javaoperator-precedence

Which has more priority: || or && or ==


I have this expression:

y[i] = ( z[i] == a && b || c )

Which of these elements (&&, ||, ==) have the priority?

Can you please show the order of operations with brackets?


Solution

  • First ==, then &&, then ||.

    Your expression will be evaluated as y[i] = (((z[i] == a) && b) || c).

    https://docs.oracle.com/javase/tutorial/java/nutsandbolts/operators.html