Signup/Sign In

Java Integer floatValue() Method

Java floatValue() method belongs to the Integer class of the java.lang package. This method returns the floating equivalent of the Integer after a widening primitive conversion(Conversion of a lower data type into a higher data type).

In short, this method is used to convert an Integer object into a float value.


public float floatValue()  


No parameter is passed in this method.


The float equivalent of the Integer object that is created after conversion.

Example 1:

Here, using the floatValue() function the Integer object is converted into its float equivalent.

import java.lang.Integer;

public class StudyTonight
    public static void main(String[] args) 
        //converting integer object into float
          Integer x = 65;
          float i=x.floatValue();
          Integer y = 90;  
          float d = y.floatValue();  


Example 2:

Here is a user-defined example where anyone using this code can put a value of his choice and get the equivalent float value.

import java.util.Scanner;  
public class StudyTonight
    public static void main(String[] args) 
              System.out.print("Enter the value to be converted : ");  
              Scanner sc = new Scanner(;  
              int i = sc.nextInt();  
              Integer n = i ;  
              float val = n.floatValue();  //converting integer object into float
              System.out.println("Float Value is: " + val);  
         catch(Exception e)
              System.out.println("not a valid integer"); 

Enter the value to be converted: 23
Float Value is: 23.0

Live Example:

Here, you can test the live code example. You can execute the example for different values, even can edit and write your examples to test the Java code.

About the author:
A Computer Science and Engineering Graduate(2016-2020) from JSSATE Noida. JAVA is Love. Sincerely Followed Sachin Tendulkar as a child, M S Dhoni as a teenager, and Virat Kohli as an adult.