在java 中怎么把double类型转成 int类型

如题所述

int numberInt ;
double numberDouble;
numberInt= (int) numberDouble;
这种方法会丢失小数点后面的值
温馨提示:答案为网友推荐,仅供参考
第1个回答  2017-06-15
double x = 2.2;
使用强制转型即可向下转型
int y = (int)x;
System.out.println(y);
相似回答