Java round () method
rint () method returns the closest int, long type value.
grammar
This method has the following syntax:
long round(double d) int round(float f)
parameter
d - double or float in the native data types
f - float native data types
return value
Returns the closest int, long type value method specified data type returned.
Examples
public class Test{ public static void main(String args[]){ double d = 100.675; double e = 100.500; float f = 100; float g = 90f; System.out.println(Math.round(d)); System.out.println(Math.round(e)); System.out.println(Math.round(f)); System.out.println(Math.round(g)); } }
Compile the above program, the output is:
101 101 100 90