Java of method overloading (overload)

What is overloaded?

In any of the classes, allowing the same name exists more than one way, so long as they have different number of parameters or parameter type can;

Heavy-duty features?

It has nothing to do with the return value, just look at the list of parameters. And the argument list must be different (the number of parameters or parameter types). When called, to distinguish between the different methods according to the parameter list.

Overloaded role?

According to the different number of parameters, the order, type, automatic matching, reduce duplication step write function name or method name.

Overloaded example:

int add(int x, int y){return x+y;}

int add(int x, int y, int z){return x+y+z;}

double add(double x, double y){return x+y;}

Guess you like

Origin www.cnblogs.com/xiximayou/p/12039931.html