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?
The logical-AND operator ( && ) has higher precedence than the logical-OR operator ( || ), so q && r is grouped as an operand.
D) | | - This operator falls under the category of Logical OR and has the lowest priority as compared to all the above-mentioned operators.
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
The priority list:
The actual expression is evaluated as
y[i] = ( ((z[i] == a) && b) || c )
You probably want to look here for more info on operator precedence. https://docs.oracle.com/javase/tutorial/java/nutsandbolts/operators.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With