# How to convert float to int in Java?

May 17, 2018You can convert a float to an int in Java by using the round method Math.round(float):

1 2 3 |
int i = Math.round(2.1f); |

The method rounds the float to the closest int value. Other methods that you can use to convert a float to int are: (int) Math.ceil(float) – returns the smallest int which is greater than or equal to the method […]