Java ternary (immediate if) evaluation

前端 未结 3 1463
南方客
南方客 2020-11-30 09:41

I can\'t find the relevant portion of the spec to answer this. In a conditional operator statement in Java, are both the true and false arguments evaluated?

So could

3条回答
  •  借酒劲吻你
    2020-11-30 10:14

    Since you wanted the spec, here it is (from §15.25 Conditional Operator ? :, the last sentence of the section):

    The operand expression not chosen is not evaluated for that particular evaluation of the conditional expression.

提交回复
热议问题