方法重载
- 方法名必须相同
- 参数必须不同
- 最常见的就是:System.out.println()里面的println源码
package com.sund.method;
public class Demo02 {
public static void main(String[] args) {
double test = test(10.0, 10.0);
System.out.println(test);
}
public static double test(double a,double b){
double sund = 0;
if(a==b){
System.out.println("a==b");
return 0;
}
if(a>b){
sund = a;
}else{
sund = b;
}
return sund;
}
public static int test(int a,int b){
int sund = 0;
if(a==b){
System.out.println("a==b");
return 0;
}
if(a>b){
sund = a;
}else{
sund = b;
}
return sund;
}
}