首先,初始化一个double值-
double val = 978.65;
现在,使用intValue()方法将Double转换为Integer值-
Double d = new Double(val); int res = d.intValue();
以下是在Java中将Double转换为Integer的程序-
public class Demo { public static void main(String args[]) { double val = 978.65; System.out.println("Double = "+val); Double d = new Double(val); int res = d.intValue(); System.out.println("Double to Integer value = "+res); } }
输出结果
Double = 978.65 Double to Integer value = 978