Hands-on brain problem issues and after-school experimental 2

Consider the following code, you find what is special about it?

 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 }

operation result

 

 Found returned overloads different parameter types are different.

Guess you like

Origin www.cnblogs.com/125418a/p/11590251.html