Overloading)
This is also called method overload.
Definition:
1. Two or more functions are in the same class;
2. The function names are the same;
3.The parameter list is different (including the type and number of parameters and the order of parameter types );
Eg:
Public Class Ol { Void Funol () {system. Out. println ( "Funol functions without Parameters" );} Void Funol ( Int I) {system. Out. println ( "Funol function with one parameter" );} Void Funol ( Int I, Float J) {system. Out. println ( "Funol functions with two parameters" );} Void Funol ( Float J, Int I) {system. Out. println ( "I am also a funol function with two parameters" );}}
Understanding: although the function name is the same, the function functions are different. Just like this function, you can wash your face, take a bath, and wash dishes;
ProgramTo identify which function to call, it is determined by the parameter list.
For exampleAn error occurs.Because the parameter list is identical, this is an error that is repeatedly defined by the same function and the compiler does not pass
VoidFunol (IntI,FloatJ) {system. Out. println ("Funol functions with two parameters");}VoidFunol (IntI,FloatK) {system. Out. println ("There are also two parameters");}