请看以下代码,你发现了有什么特殊之处吗?
1 // MethodOverload.java
2 // Using overloaded methods
3
4 public class DDD {
5
6 public static void main(String[] args) {
7 System.out.println("The square of integer 7 is " + square(7));
8 System.out.println("\nThe square of double 7.5 is " + square(7.5));
9 }
10
11 public static int square(int x) {
12 return x * x;
13 }
14
15 public static double square(double y) {
16 return y * y;
17 }
18 }
运行结果

发现重载函数参数类型不同返回的值也不同。