package test22;
class caculator{
public void Add(int a,int b) {
int c=a+b;
System.out.println("两个整数相加得:"+c);
}
public void Add(int a,int b,int d) {
int c=a+b+d;
System.out.println("三个整数相加得:"+c);
}
public void Add(float a,float b) {
float c=a+b;
System.out.println("两个浮点数相加得:"+c);
}
public void Add(String a,String b) {
String c=a+b;
System.out.println("两个字符串相加得:"+c);
}
}
public class OverLoad {
public static void main(String arg[]) {
caculator c=new caculator();
c.Add(1, 6);
c.Add(2, 8, 5);
c.Add(2.5f, 5.2f);
c.Add("hello","世界");
}
}
class caculator{
public void Add(int a,int b) {
int c=a+b;
System.out.println("两个整数相加得:"+c);
}
public void Add(int a,int b,int d) {
int c=a+b+d;
System.out.println("三个整数相加得:"+c);
}
public void Add(float a,float b) {
float c=a+b;
System.out.println("两个浮点数相加得:"+c);
}
public void Add(String a,String b) {
String c=a+b;
System.out.println("两个字符串相加得:"+c);
}
}
public class OverLoad {
public static void main(String arg[]) {
caculator c=new caculator();
c.Add(1, 6);
c.Add(2, 8, 5);
c.Add(2.5f, 5.2f);
c.Add("hello","世界");
}
}