动手动脑2

 

;
public class MethodOverload {

public static void main(String[] args) {
System.out.println("The square of integer 7 is " + square(7));
System.out.println("\nThe 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;
}
}

 

     答:代码中的两个方法,方法名相同,但返回值类型和参数类型都不同.。这又叫做重载。

 

posted @ 2017-10-14 01:26  pangkaxxxl  阅读(71)  评论(0编辑  收藏  举报