Java.lang.Double.intValue() 方法
描述
java.lang.Double.intValue() 方法将此 Double 的值作为 int 返回(通过转换为 int 类型)。
声明
以下是 java.lang.Double.intValue() 方法的声明。
public int intValue()
参数
NA
返回值
此方法返回由转换为 int 类型的此对象表示的双精度值。
异常
NA
示例
下面的例子展示了 java.lang.Double.intValue() 方法的使用。
package com.tutorialspoint;
import java.lang.*;
public class DoubleDemo {
public static void main(String[] args) {
/* returns the double value represented by this object
converted to type int */
Double obj = new Double("32.90");
int i = obj.intValue();
System.out.println("Value = " + i);
obj = new Double("30.0");
i = obj.intValue();
System.out.println("Value = " + i);
}
}
让我们编译并运行上面的程序,这将产生下面的结果 −
Value = 32 Value = 30

