?? testmethodoverloading.java
字號:
package problem_4;
//TestMethodOverloading.java
public class TestMethodOverloading {
public static void main(String[] args) {
System.out.println("Max number of integer 3 and 4 is " + Max(3,4) + ";");
System.out.println("Max number of double float numbers 3.0 and 5.4 is " + Max(3.0,5.4) + ";");
System.out.println("Max number of double float numbers 3.0, 5.4 and 10.14 is " + Max(3.0,5.4,10.14));
}
//返回兩個整型數中的較大者
public static int Max(int a, int b){
return a>b?a:b;
}
//返回兩個雙精度浮點數中的較大者
public static double Max(double a, double b){
return a>b?a:b;
}
//返回三個雙精度浮點數中的最大者
public static double Max(double a, double b, double c){
double temp = a;
if(temp < b)
temp = b;
if(temp < c)
temp = c;
return temp;
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -