Latest web development tutorials

Java rint () method

Java Number classes Java Number classes


rint () method returns an integer value closest parameters.

grammar

This method has the following syntax:

double rint(double d)

parameter

  • double the raw data type.

return value

Returns an array of double type, is an integer value closest to the argument.

Examples

public class Test{
	public static void main(String args[]){
		double d = 100.675;
		double e = 100.500;
		double f = 100.200;

		System.out.println(Math.rint(d));
		System.out.println(Math.rint(e)); 
		System.out.println(Math.rint(f)); 
	}
}

Compile the above program, the output is:

101.0
100.0
100.0

Java Number classes Java Number classes