84669 person learning
152542 person learning
20005 person learning
5487 person learning
7821 person learning
359900 person learning
3350 person learning
180660 person learning
48569 person learning
18603 person learning
40936 person learning
1549 person learning
1183 person learning
32909 person learning
java里自定义类重载有什么用?
认证高级PHP讲师
It should be convenient to use. The parameters passed in the function are different but the function is the same. I think it's a habit and style. You don’t have to do this either
In fact, in my opinion, there are only 4 situations for all functions. Overloading is for contextual semantics: For example:
void say(String name, Integer age) void say(String name)
Of course you will say that you can define a wide range of input parameter lists to include the possibility of all subsets;
For example
void say(String name, Integer age, String address){ if(name!=null){ .... } if(age!=null){ ... } ... } 那么使用的时候反而增大了操作量比如 say("张三",null,null);
It should be convenient to use. The parameters passed in the function are different but the function is the same. I think it's a habit and style. You don’t have to do this either
In fact, in my opinion, there are only 4 situations for all functions.
Overloading is for contextual semantics:
For example:
Of course you will say that you can define a wide range of input parameter lists to include the possibility of all subsets;
For example