String concatenation does not work properly in Java when concatenating 2 results of ternary operators

前端 未结 4 1447
无人及你
无人及你 2021-01-03 05:05

Dear Java guru \'s!

Can you, please, explain me, why String concatenation does not work properly in Java when concatenating 2 results of ternary operators?

4条回答
  •  悲&欢浪女
    2021-01-03 05:36

    "B" + str == null ? "C", String concatenation evaliated first before the conditional expression evaluated

提交回复
热议问题