Java Float - floatValue() Method
The java.lang.Float.floatValue() method returns the float value of this Float object.
Syntax
public float floatValue()
Parameters
No parameter is required.
Return Value
Returns the float value represented by this object.
Exception
NA.
Example:
In the example below, the java.lang.Float.floatValue() method returns the given Float object as a float.
import java.lang.*; public class MyClass { public static void main(String[] args) { //creating Float objects Float val1 = 25f; Float val2 = -25f; //printing floatValue of the Float objects System.out.println("floatValue of the val1 is: " + val1.floatValue()); System.out.println("floatValue of the val2 is: " + val2.floatValue()); } }
The output of the above code will be:
floatValue of the val1 is: 25.0 floatValue of the val2 is: -25.0
❮ Java.lang - Float