1. overloaded function
Code:
1 // MethodOverload.java 2 // Using overloaded methods 3 4 public class MethodOverload { 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 }
Thought procedure: different types of data types overloaded functions implemented by the square calculation.
Harvest procedure: three heavy-duty overloads ways: 1. Overload 2. Type parameter parameter parameter sequence number 3. Overload overloaded.