The java.lang.Integer.floatValue() method of Integer class of java.lang package is used to convert the value of the given Integer to a float type after a widening primitive conversion.
Syntax :
public float floatValue()
Parameters: The method does not accepts any parameter.
Return Value: The method returns the numeric value represented by this object after converting it to type float.
Below programs illustrate the java.lang.Integer.floatValue() method:
Program 1:
// Java program to demonstrate working// of java.lang.Integer.floatValue() methodimport java.lang.Integer; class Gfg { // Driver code public static void main(String args[]) { Integer a = new Integer(28); // Convert Integer number to float value float b = a.floatValue(); System.out.println(b); }} |
28.0
Program 2:
// Java program to demonstrate working// of java.lang.Integer.floatValue() methodimport java.lang.Integer; class Gfg { // Driver code public static void main(String args[]) { Integer a = new Integer(20); // Convert Integer number to float value float b = a.floatValue(); System.out.println(b); }} |
20.0
Attention reader! Don’t stop learning now. Get hold of all the important Java Foundation and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready. To complete your preparation from learning a language to DS Algo and many more, please refer Complete Interview Preparation Course.


