Convert double to Int, rounded down

前端 未结 5 1539
心在旅途
心在旅途 2020-12-15 02:26

How to convert a double value to int doing the following:

Double If x = 4.97542. Convert to int x = 4.

Double If x = 4.23544. Conv         


        
5条回答
  •  臣服心动
    2020-12-15 03:31

    double myDouble = 420.5;
    //Type cast double to int
    int i = (int)myDouble;
    System.out.println(i);
    

    The double value is 420.5 and the application prints out the integer value of 420

提交回复
热议问题