This is because the signatures of static methods and instance methods cannot be the same, because Java allows calling class static methods on instance objects. It is precisely because of this permission that methods with the same signature cannot be used. See example:
public class Test {
// public void main(String[] args) {} // Error
public static void main(String[] args) {
Test.hello(); // OK
new Test().hello(); // OK
}
public static void hello() {
System.out.println("hi");
}
}
So who do you think jvm should execute? Even if they are all normal methods, they cannot use the same name and the same parameters. The jvm will be stupid
Both static and abstract methods are defined by classes. Since they are all defined by classes, they must not have the same name and the same parameters.
This is because the signatures of static methods and instance methods cannot be the same, because Java allows calling class static methods on instance objects. It is precisely because of this permission that methods with the same signature cannot be used. See example:
So who do you think jvm should execute?
Even if they are all normal methods, they cannot use the same name and the same parameters. The jvm will be stupid
Method signature: The uniqueness of the method is determined by method name and parameter data type
The method names and parameters of the above two methods are consistent, resulting in an error during the compilation processdynamic bindingfeature
Both static and abstract methods are defined by classes. Since they are all defined by classes, they must not have the same name and the same parameters.
Overloading and rewriting in Java do not allow such rules.