Java operators precedence

前端 未结 2 1347
渐次进展
渐次进展 2020-12-07 03:04

I have got confused due to what is true regarding the operator precedence in Java. I read in tutorials a long time ago that AND has a higher priority than OR, which is confi

2条回答
  •  广开言路
    2020-12-07 04:07

    That's because it is using the | operator instead of ||, which has a higher priority. Here's the table.

    Use the || operator instead and it'll do what you think.

提交回复
热议问题