Java Tutorial

Java Control Statements

Object Oriented Programming

Java Built-in Classes

Java File Handling

Java Error & Exceptions

Java Multithreading

Java Synchronization

Java Networking

Java Collections

Java List Interface

Java Queue Interface

Java Map Interface

Java Set Interface

Java Data Structures

Java Collections Algorithms

Java Miscellaneous

Advanced Java

Java APIs & Frameworks

Java Useful Resources

Java - rint() Method



Description

The method rint returns the integer that is closest in value to the argument.

Syntax

double rint(double d)

Parameters

Here is the detail of parameters −

  • d − it accepts a double value as parameter.

Return Value

  • This method returns the integer that is closest in value to the argument. Returned as a double.

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

This will produce the following result −

Output

101.0
100.0
100.0
java_numbers.htm
Advertisements