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

后端 未结 6 1412
暗喜
暗喜 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 10:51

    yes it is absolutely valid compare int datatype and double datatype..

    int i =10;
    double j= 10.0;
     if (i==j)
    {
    System.out.println("IT IS TRUE");
    }
    

提交回复
热议问题