第二次实验报告动手动脑

返回值不一样  一个是int整形  一个是double类型

还有就是没有写输出语句直接用对方法赋值的方法进行计算

public class MethodOverload {
public static void main(String[] args) {
System.out.println("The square of integer 7 is"+square(7));
System.out.println(" The square of double 7.5 is"+square(7.5));
}

public static int square(int x) {
return x*x;
}

public static double square(double y) {
return y*y;
}
}

原文地址:https://www.cnblogs.com/0518liu/p/9787189.html