Java Integer floatValue() method returns the value of this Integer object as float after performing widening primitive conversion (Integer -> float).
Hierarchy:
java.lang Package
-> Integer Class
-> floatValue() Method
Syntax of floatValue() method
public float floatValue()
floatValue() Parameters
NA
floatValue() Return Value
- It returns a float value equivalent to the value represented by this Integer object.
Supported java versions: Java 1.2 and onwards.
Example 1
public class JavaExample {
public static void main(String[] args) {
Integer i = new Integer("102");
Integer i2 = new Integer(15);
float d = i.floatValue();
float d2 = i2.floatValue();
System.out.println("Value of Integer i as float: "+d);
System.out.println("Value of Integer i2 as float: "+d2);
}
}
Output:

Example 2
import java.util.Scanner;
public class JavaExample{
public static void main(String[] args){
Integer i;
//taking integer value from user
Scanner scan = new Scanner(System.in);
System.out.print("Enter any integer number: ");
i = scan.nextInt();
float f = i.floatValue();
System.out.println("Entered value as float: "+f);
}
}
Output:

Example 3
public class JavaExample {
public static void main(String[] args) {
int num = 1234; //primitive int data type
Integer i = new Integer(num); //int to Integer object
float f = i.floatValue(); //Integer to float
System.out.println("Value of num as float: "+f);
}
}
Output:
