Home  >  Article  >  Java  >  How to solve the invalidity of java method overloading

How to solve the invalidity of java method overloading

WBOY
WBOYforward
2023-04-19 22:34:051151browse

Overloading is invalid

1. When talking about the parameter list, the return type of the method is not discussed.

2. If two methods have the same name, the same parameters and different return types, then this is not a valid method overload and will result in a compilation error.

int add(int, int)
float add(int, int)

Overloading Description

In a class, there are two or more methods with the same method name but different parameter lists. These methods are called each other. Overloaded methods.

Overloading Note

(1) Static polymorphism is also called compile-time binding or early binding.

(2) Static binding occurs during the compilation process. Method overloading is an example of static binding, where method invocation defines binding that occurs during compilation.

What are the basic data types of java

The basic data types of Java are divided into:

1. Integer type, used to represent the data type of integer.

2. Floating point type, a data type used to represent decimals.

3. Character type. The keyword of character type is "char".

4. Boolean type is the basic data type that represents logical values.

The above is the detailed content of How to solve the invalidity of java method overloading. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:yisu.com. If there is any infringement, please contact admin@php.cn delete