[Solved] What if the meaning of that expression if(x > y / z)


It’s x > (y / z). The expression y / z returns a number which is being compared to x.

The operator precedence table explains why it works even without round brackets.

┌────────────────┬───────────────────────────────┐
│   Operators    │          Precedence ↓         │
├────────────────┼───────────────────────────────┤
│ multiplicative │ * / %                         │
│ relational     │ < > <= >= instanceof          │ 
└────────────────┴───────────────────────────────┘

A simple example

System.out.println((10 == 20 / 2) ? "correct" : "incorrect");

prints

correct

2

solved What if the meaning of that expression if(x > y / z)