Java logical operator (&&, ||) short-circuit mechanism

后端 未结 6 2010
野的像风
野的像风 2021-02-19 06:28

As I was reading a colleague\'s Java code, I stumbled upon an army of if/else statements. In these statements, several && and || operators wer

6条回答
  •  广开言路
    2021-02-19 06:54

    for &&:

    false && ... => false

    for ||:

    true || ... => true.

    And precedence for && is higher than ||.

    See more: Operator Precedence in Java

提交回复
热议问题