Convert Int to Float in Java
Lovey Arora
Jul 27, 2021
-
Use the
floatValue()
Function to Convert an Integer Into a Float in Java - Use the Typecasting Method to Convert an Integer Into a Float in Java

Float values represent decimal point numbers in Java. It is one of the fundamental data types used in almost all programming languages.
This tutorial will demonstrate how to convert integer to float in Java.
Use the floatValue()
Function to Convert an Integer Into a Float in Java
The floatValue()
function can convert a given integer value into float. It belongs to the java.lang.Integer
class.
For example,
import java.lang.Integer;
public class Main {
public static void main(String args[])
{
Integer a = new Integer(56);
float b = a.floatValue();
System.out.println(b);
}
}
Output:
56.0
Use the Typecasting Method to Convert an Integer Into a Float in Java
Typecasting is a method in which you convert one type of data type into some other type explicitly. By using this technique, we can convert an integer value into a float value.
To typecast an integer value to float, we will use the float
keyword.
See the code given below.
public class Main {
public static void main(String args[])
{
int i = 56;
float f = i;
System.out.println(f);
}
}
Output:
56.0
Related Article - Java Float
- Float and Double Data Type in Java
- Convert Double to Float in Java
- Convert Float to String and String to Float in Java
- Print a Float With 2 Decimal Places in Java
Related Article - Java Integer
- Handle Integer Overflow and Underflow in Java
- Reverse an Integer in Java
- Convert Int to Binary in Java
- The Max Value of an Integer in Java
- Minimum and Maximum Value of Integer in Java
- Convert Integer to Int in Java