Math.round(float a) has the following syntax.
public static int round(float a)
In the following code shows how to use Math.round(float a) method.
//from ww w . j a v a 2 s . c o m public class Main { public static void main(String[] args) { float x = 1234.1234f; float y = -1234.123f; // find the closest int for these floats System.out.println("Math.round(" + x + ")=" + Math.round(x)); System.out.println("Math.round(" + y + ")=" + Math.round(y)); } }
The code above generates the following result.