Java method Overloading
Class ChongZai {
Public void a (int );
Public void a (Strting );
Public void a (int a, int B );
}
The above is an overload, and the overload must meet the following conditions:
1. Must beSame class
2.The method name (or function) is the same.
3.The parameter type is different or the number of parameters is different.
The role of overload:
Or the above example
ChongZai cz = new ChongZai ();
Cz. a (1); // call a (int );
Cz. a ("passed parameter"); // call a (String)
Cz. a (1, 2); // call a (int a, int B)
Which method is called, and the program determines which method to call based on the parameters you enter.
Reload functions:
For example, if you are playing a game, you may be able to have multiple people complete the game. If you are not sure that you are a few people, you can use the heavy load.
For example, you can define up to three parameters.
Public void a (String );
Public void a (String a, String B );
Public void a (String a, String B, String c );
For two people, you can call the two parameter methods. For three people, you can call the three parameter methods.