Java.lang.Float.doubleValue() Method


Advertisements


Description

The java.lang.Float.doubleValue() method returns the double value of this Float object.

Declaration

Following is the declaration for java.lang.Float.doubleValue() method

public double doubleValue()

Parameters

  • NA

Return Value

This method returns the float value represented by this object is converted to type double and the result of the conversion is returned.

Exception

  • NA

Example

The following example shows the usage of java.lang.Float.doubleValue() method.

package com.tutorialspoint;

import java.lang.*;

public class FloatDemo {

   public static void main(String[] args) {

   /* returns the float value represented by this object
   converted to type double */
   Float obj = new Float("22.10f");
   double d = obj.doubleValue();
   System.out.println("Value = " + d);
    
   obj = new Float("5.0");
   d = obj.doubleValue();
   System.out.println("Value = " + d);
   }
}  

Let us compile and run the above program, this will produce the following result:

Value = 22.100000381469727
Value = 5.0

java_lang_float.htm

Advertisements