java里自定义类重载ClassLoader有什么用?
PHP中文网
PHP中文网 2017-04-18 10:48:49
0
2
610

java里自定义类重载有什么用?

PHP中文网
PHP中文网

认证高级PHP讲师

reply all(2)
小葫芦

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);
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!