In this Java tutorial, you will learn about Integer.floatValue()
method, and how to use this method to get equivalent float value of this Integer object, with the help of examples.
Integer.floatValue()
Integer.floatValue()
returns the value of this Integer as a float after a widening primitive conversion.
Syntax
The syntax of floatValue() method is
</>
Copy
Integer.floatValue()
Returns
The method returns value of type float.
Example
In this example, we will take an Integer object and get its equivalent float value using Integer.floatValue() method.
Java Program
</>
Copy
public class Example {
public static void main(String[] args){
Integer integer = 20;
float result = integer.floatValue();
System.out.println("Result of floatValue() = " + result);
}
}
Output
Result of floatValue() = 20.0
Conclusion
In this Java Tutorial, we have learnt the syntax of Java Integer.floatValue() method, and also how to use this method with the help of Java example programs.