intValue
public int intValue()Returns the value of this Double as an int (by casting to type int). Specified by:
intValue in class Number
Returns:
the double value represented by this object converted to type int

解决方案 »

  1.   

    你可以用
    double Math.ceil(double) 将一个数舍入为大于等于他的最小整数
    double Math.floor(double)将一个数舍入为小于等于他的最小整数
    double Math.rint(double) 将一个浮点数舍入为同他的最接近的整数
    int Math.round(float)   将一个浮点数舍入为同他最接近的整数
      

  2.   

    double x=12.6;
    int nx=(int)Math.round(x);//四舍五入方法,nx=13;还有简单的去掉小数部分:
    double x=12.6;
    int nx=(int)x;//nx=12;