Java rint() 方法
rint() 方法返回最接近參數的整數值。
語法
該方法有以下幾種語法格式:
double rint(double d)
參數
- double 原始數據類型。
 
返回值
返回 double 類型數組,是最接近參數的整數值。
實例
實例
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));
    }
}
編譯以上程式,輸出結果為:
101.0 100.0 100.0

Java Number類