class A {
float add(int a,int b) {
return a+b;
}
float add(long a,int b) {
return a+b;
}
double add(double a,int b) {
return a+b;
}
}
PS:见示例
创建主类 Demo18
public class Demo18 {
public static void main(String[] args) {
Circle circle = new Circle();
circle.setRadius(12.5);
Ladder ladder = new Ladder(10, 20, 15);
People people = new People();
System.out.println("people计算圆的面积:"+people.computerArea(circle));
System.out.println("people计算梯形的面积:"+people.computerArea(ladder));
}
}
创建类Circle
public class Circle {
double radius, area; // 半径 和面积
void setRadius(double r) { //设置半径方法
radius = r; //对r进行赋值
}