Java overloaded function

 
Function overloading: For a class function, the same function name, parameters are not the same, it's our relationship is called overloading
Different forms of parameters: the number of different types
The reason: real time to identify the function of internal procedures are identified in the function name + type of all parameters
Precautions: the essence overloaded function are different functions
to sum up:
1. The function name must be the same
2. The parameters must be different: the number of positions of different types of relationship constitutes reload
3. Overloading and return value does not matter
 
public static int sum(int a,int b){
    return 5;
}
public static int sum (int b, int a) {// the same type of function names
    return 5; // not overloaded with 1
}

Guess you like

Origin www.cnblogs.com/fuyunhou-boke-07/p/11332696.html