| 方法 | 描述 |
|---|---|
| long round(double d) int round(float f) | 回傳最接近參數的整數值 |
舉例如下
class RoundDemo {
public static void main(String[] args) {
System.out.println(Math.round(9.0));
System.out.println(Math.round(9.1));
System.out.println(Math.round(9.2));
System.out.println(Math.round(9.3));
System.out.println(Math.round(9.4));
System.out.println(Math.round(9.5));
System.out.println(Math.round(9.6));
System.out.println(Math.round(9.7));
System.out.println(Math.round(9.8));
System.out.println(Math.round(9.9));
}
}
/* 《程式語言教學誌》的範例程式
http://pydoing.blogspot.com/
檔名:RoundDemo.java
功能:示範物件導向的基本觀念
作者:張凱慶
時間:西元 2010 年 10 月 */編譯後執行,結果如下

| 中英文術語對照 | |
|---|---|
| 方法 | method |
| 參數 | parameter |
沒有留言:
張貼留言