在Java中将Double转换为Integer
首先,初始化一个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
热门推荐
2 初八祝福语简短语
6 十月简短祝福语
10 潮汕生日谚语祝福语简短
11 参加婚礼祝福语大全简短
12 简短的出行工作祝福语
13 喜事敬酒祝福语简短精辟
14 新房开工吉日祝福语简短
15 下雪宝宝生日祝福语简短
16 新疆新年祝福语大全简短
17 生日祝福语 简短独特高考
18 同事离别祝福语简短的