Java Float doubleValue()方法及示例
Float类的 doubleValue() 方法是一个内置的方法,用于返回调用对象指定的、经过类型转换的双倍值。
语法:
FloatObject.doubleValue()
返回值: 它返回该Float对象的 双倍 值。以下程序说明了Java中的doubleValue()方法:
程序1 :
// Java code to demonstrate// Float doubleValue() method class GFG { public static void main(String[] args) { // Float value float a = 17.65f; // wrapping the Float value // in the wrapper class Float Float b = new Float(a); // doubleValue of the Float Object double output = b.doubleValue(); // print doubling the output System.out.println("Float value of " + b + " is : " + output); }}
输出
Float value of 17.65 is : 17.649999618530273
程序2
// Java code to demonstrate// Float doubleValue() method class GFG { public static void main(String[] args) { // Float value float a = 6.0f; // wrapping the Float value // in the wrapper class Float Float b = new Float(a); // doubleValue of the Float Object double output = b.doubleValue(); // print doubling the output System.out.println("Float value of " + b + " is : " + output); }}
输出
Float value of 6.0 is : 6.0
参考资料 : https://docs.oracle.com/javase/7/docs/api/java/lang/Float.html#doubleValue()
