| 方法 | 描述 |
|---|---|
| double max(double arg1, double arg2) float max(float arg1, float arg2) int max(int arg1, int arg2) long max(long arg1, long arg2) | 回傳參數中的較大值 |
舉例如下
class MaxDemo {
public static void main(String[] args) {
System.out.println(Math.max(35, 48));
System.out.println(Math.max(22.3, 22.1));
System.out.println(Math.max(0.00365f, 0.00365002f));
System.out.println(Math.max(652l, 965l));
}
}
/* 《程式語言教學誌》的範例程式
http://pydoing.blogspot.com/
檔名:MaxDemo.java
功能:示範物件導向的基本觀念
作者:張凱慶
時間:西元 2010 年 10 月 */編譯後執行,結果如下

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