Introduction
In Java, the doubleValue() is a method of the Float class that returns the numerical equivalent of a Float object after converting it into a double type. This lab will guide you through the steps of using the doubleValue() method in Java.
Create a Java class
Create a Java class named FloatDoubleValue using the below command:
touch FloatDoubleValue.java
Import required packages
Import the required package java.lang.Float using the import statement at the beginning of the code:
import java.lang.Float;
Implement the doubleValue() method
Create an instance of Float class and pass a float value to it. Then use the doubleValue() method to convert the Float object to a double type.
Float x = 99.12f;
double i=x.doubleValue();
System.out.println("Equivalent double value is " +i);
Execute the program
Compile the program using the below command:
javac FloatDoubleValue.java
Run the program using the below command:
java FloatDoubleValue
You will see the output on the terminal:
Equivalent double value is 99.12000274658203
Summary
In this lab, you learned how to use the doubleValue() method of the Float class to convert a Float object into its numerical double equivalent. You also learned how to create a Java class, import required packages, implement the doubleValue() method, and execute the Java program in the terminal.



