implicit conversion in java operator +=

前端 未结 2 987
后悔当初
后悔当初 2020-12-06 06:21

I\'ve found that java compile has a non-expected behavior regarding assignment and self assignment statements using an int and a float.

The following code block illu

2条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-06 06:59

    i believe that the explicit i+f fails because of Narrowing primitive conversion. While in the first case the conversion on the right side passes because it is done according to Compound Assignment rules.

提交回复
热议问题