short-circuiting behavior of conditional OR operator(||)

前端 未结 3 973
北恋
北恋 2020-12-06 16:49

Both conditional operators && and || are short-circuited as per
http://docs.oracle.com/javase/tutorial/java/nutsandbolts/op2.html, which means the second operand

3条回答
  •  春和景丽
    2020-12-06 17:05

    if (true || comparison)
    

    comparison will never be evaluated, since its result is irrelevant (because the first argument is already true).

提交回复
热议问题