方法重载(二)

方法重载练习二:求各种最大值

用重载实现:
定义方法求两个整数的最大值
定义方法求三个整数的最大值
定义方法求两个小数的最大值

//求两个整数的最大值
public int max(int a,int b){
    return a>b?a:b;
}
	
//求三个整数的最大值
public int max(int a, int b, int c){
    return max(max(a,b),c);
}
	
//求两个小数的最大值
public double max(double a, double b){
    return a>b?a:b;
}

  

原文地址:https://www.cnblogs.com/panyizuoshan/p/11398326.html