Facebook Page Twitter Page LinkedIn Page
× Java.lang Package Classes


The java.lang.Float.floatValue() method is used to return 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 below example, the java.lang.Float.floatValue() method is used to return the given Float object as a float.

import java.lang.*;

public class MyClass {
  public static void main(String[] args) {
    
    //creating Float objects
    Float val1 = new Float("25f");
    Float val2 = new Float("-25");

    //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