java method's overload
Method overloading the range: a class inside
How to determine the method of overload:
1, the number of parameters in different ways
2, different types of method parameters
3, the number and types of method parameters are equal, their order of different methods are also considered heavy
Note: The method returns the parameter type, and not as a way to judge whether the overload factor.
java method's overriding
Overriding will occur: Child extends Father this relation
How to determine whether the rewrite?:
If the child class defines a method with the parent class has the same name and parameters, and the method return value type and the type of exception is thrown their consistency with the parent, we say that the method has been rewritten (Overriding)
Subclass object using this method is called sub-class definition, it is concerned, the definition of the parent class as being "shielded" the.
Other: static, native and synchronized methods can not be overriding.
Method overloading the range: a class inside
How to determine the method of overload:
1, the number of parameters in different ways
2, different types of method parameters
3, the number and types of method parameters are equal, their order of different methods are also considered heavy
Note: The method returns the parameter type, and not as a way to judge whether the overload factor.
java method's overriding
Overriding will occur: Child extends Father this relation
How to determine whether the rewrite?:
If the child class defines a method with the parent class has the same name and parameters, and the method return value type and the type of exception is thrown their consistency with the parent, we say that the method has been rewritten (Overriding)
Subclass object using this method is called sub-class definition, it is concerned, the definition of the parent class as being "shielded" the.
Other: static, native and synchronized methods can not be overriding.
本文详细解释了Java中方法重载(overloading)的判断标准,包括参数数量、类型及顺序的不同;以及方法重写(overriding)的条件,即子类方法与父类方法名称、参数列表相同,返回类型及抛出异常一致的情况。
984

被折叠的 条评论
为什么被折叠?



