Java StrictMath.rint(double a)
Syntax
StrictMath.rint(double a) has the following syntax.
public static double rint(double a)
Example
In the following code shows how to use StrictMath.rint(double a) method.
/*www . ja v a2 s . c o m*/
public class Main {
public static void main(String[] args) {
double d1 = 1.2 , d2 = 34.5 , d3 = 6.7;
System.out.println("integer value closest to " + d1 + " = " + StrictMath.rint(d1));
System.out.println("integer value closest to " + d2 + " = " + StrictMath.rint(d2));
System.out.println("integer value closest to " + d3 + " = " + StrictMath.rint(d3));
}
}
The code above generates the following result.