****方法的重载机制*******
1,方法重载又被称为:overload
2,什么时候考虑方法重载?
*功能相似的时候尽可能让方法名相同
*
*但是功能不同,不相似的时候尽可能让名字相同
3,什么条件构成方法重载》?
*在同一个类中
*
*方法名相同
*参数列表不同
4,方法重载和什么有关系,和什么没关系?
方法名相同,参数类型不同
,参数个数不同
,参数顺序不同
public class Overload {
public static void main(String[] args) {
int a = 10;
int b = 20;
int retValue = sumInt(a,b);
System.out.println("retValue" + retValue);
}
public static int sumInt(int i,int j) {
int result = i + j;
int num = 3;
int retValue = divide(result,num);
return retValue;
}
public static int divide(int x,int y){
int z = x/y;
return z;
}
}