Overload overwrite override in Java

Source: Internet
Author: User

The following concepts have been vague:

Overload (overload) Key Words: None 1. used: in the same class. (Actually, different versions of methods with the same name in the same class

A name)

2. Requirements for methods to be reloaded and methods to be reloaded: The parameter list is different or the return type is different or

Different users

Overwrite (rewrite) Keyword: New is used to inherit from the parent class and is the same as the method name of the new keyword.

The method is invalid, just as it does not exist in the parent class. As long as the method name is the same, there is no need for anything else.

.

Override (overwrite) Keyword: override

1. The override method must be of the parent class (direct parent class or indirect parent class (that is, the parent class of the Top N layer ).

(Class) virtual methods or abstract methods, where abstract methods must be overwritten.

2. The three parts must be the same
The same method name;
The same parameter list;

Returns the same type.

 

Baidu knows that a renxiong wrote:

Overload is a completely new method. The parameters are different from the original method.
Override overwrites the inherited method, which is still not abandoned.
Overwrite overwrites the code of the inherited method. The original method is abandoned.

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.