Is it valid to compare a double with an int in java?

后端 未结 6 1394
暗喜
暗喜 2020-11-28 10:41
Utilities.getDistance(uni, enemyuni) <= uni.getAttackRange()

Utilities.getDistance returns double and getAttackRange returns int. The above code

6条回答
  •  一生所求
    2020-11-28 11:13

    This should be fine. In floating point operation/comparisons, if one argument is floating/double then other one being int is also promoted to the same.

提交回复
热议问题