Java StrictMath.round(float a)
Syntax
StrictMath.round(float a) has the following syntax.
public static int round(float a)
Example
In the following code shows how to use StrictMath.round(float a) method.
/* ww w .j a va 2 s .c o m*/
public class Main {
public static void main(String[] args) {
float f1 = 12.34f , f2 = 56.78f;
System.out.println("closest int value to " + f1 + " = " + StrictMath.round(f1));
System.out.println("closest int value to " + f2 + " = " + StrictMath.round(f2));
}
}
The code above generates the following result.