How to identify a variable and method in java

For variables, use the variable name to identify. For a , you can't require it to be both an int and a double. This is wrong;

Similarly, for a method, its method signature is: method name + parameter Through the signature, a method has been identified. You cannot require a method to have more than one return type. Therefore, the semantic category of overloading is the method signature. Even if the method name is the same, the number or types of parameters are different, it can be considered as a different method, no error will be reported, and at the same time, it expresses multiple method implementations of the same operation.

For a class that implements two interfaces, if the two interfaces contain the same method signature, even if the return types are different, they are considered to be the same method, and an error will be reported, and the implementing class will struggle with which type to return. (The variable is also, the same variable cannot appear in the two interfaces being implemented... although it is actually a constant)

So, the method signature is identified.

Avoid these situations.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325350395&siteId=291194637