Java.lang.Integer.floatValue() 方法
描述
java.lang.Integer.floatValue() 方法将此 Integer 的值作为浮点数返回。
声明
以下是 java.lang.Integer.floatValue() 方法的声明。
public float floatValue()
参数
NA
返回值
该方法返回此对象转换为float类型后所表示的数值。
异常
NA
示例
下面的例子展示了 java.lang.Integer.floatValue() 方法的使用。
package com.tutorialspoint;
import java.lang.*;
public class IntegerDemo {
public static void main(String[] args) {
Integer obj = new Integer(35);
// returns the value of this Integer as a float
float f = obj.floatValue();
System.out.println("Value of f = " + f);
}
}
让我们编译并运行上面的程序,这将产生下面的结果 −
Value of f = 35.0

