方法名相同,参数类型,数量,排列顺序不同
//比大小 public class demo01 { public static void main(String[] args) { int num=(int)add(0.5,0.4); System.out.println(num); } public static int add(int a,int c){ int result =0; if(a==c){ System.out.println("两个值相等"); return 0; } if (a>c){ result=a;} else { result=c;} return result; } public static double add(double a,double c){ double result =0.1; if(a==c){ System.out.println("两个值相等"); return 0; } if (a>c){ result=(int)a;} else { result=(int)c;} return result; } }