Why instance method cannot override the static method
本问题已经有最佳答案,请猛点这里访问。
1 2 3 4 5 6 7 8 9 10 11 |
编译器在第3行给出错误,说
This instance method cannot override the static method from Abc
为什么静态方法不能被实例方法重写?
简单的说:"因为语言规范等。 P / < >
那是一个乐队的downsides静态方法:没有polymorphism为他们。conceptually,他们是不是意思是overridden。这是所有有到这。 P / < >
到最精确的说:"JLS differentiates之间的静态和非静态方法和国家: P / < >
An instance method is always invoked with respect to an object, which becomes the current object to which the keywords this and super refer during execution of the method body.