search
HomeJavaJavaBaseThe difference between overloading and rewriting in java

The difference between overloading and rewriting in java

The difference between java overloading and rewriting: (Recommended: java video tutorial)

1. Definition difference:

① Overloading means that different functions use the same function name, but the number or type of parameters of the function is different. Different functions are distinguished according to the parameters of the function when calling.

②Overwriting (also called rewriting) refers to reimplementing the virtual function (note that it is a virtual function) in the base class in the derived class. That is, the function name and parameters are the same, but the implementation of the function is different.

2. The difference in class relationships

Overlay is the relationship between subclasses and parent classes, which is a vertical relationship; overloading is the relationship between methods in the same class, which is a horizontal relationship. .

3. Differences in generating methods

Override can only be generated by one method or a pair of methods; overloading is the relationship between multiple methods.

4. Difference in parameter list requirements

Overwriting requires the same parameter list; overloading requires different parameter lists.

5. Differences in calling methods

In the coverage relationship, the calling method body is determined based on the type of the object; while the overloading relationship is selected based on the actual parameter list and formal parameter list when calling. method body.

For more java knowledge, please pay attention to the java basic tutorial column.

The above is the detailed content of The difference between overloading and rewriting in java. For more information, please follow other related articles on the PHP Chinese website!

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version