Java.lang Package Classes

Java Integer - floatValue() Method

The java.lang.Integer.floatValue() method returns the value of this Integer as a float after a widening primitive conversion.


public float floatValue()


No parameter is required.

Return Value

Returns the numeric value represented by this object after conversion to type float.




In the example below, the java.lang.Integer.floatValue() method returns a Integer object after conversion to type float.

import java.lang.*;

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

    //printing floatValue of the Integer 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 - Integer