Easy Tutorial
❮ Java String Substring Exception Thread ❯

Java rint() Method

Java Number Class


The rint() method returns the integer value that is closest to the parameter.

Syntax

The method has the following syntax formats:

double rint(double d)

Parameters

Return Value

Returns a double type array, which is the integer value closest to the parameter.

Example

Example

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)); 
    }
}

Compiling the above program will output the following:

101.0
100.0
100.0

Java Number Class

❮ Java String Substring Exception Thread ❯