更新时间:2023-10-05 14:31:58
你真的没有理由可以真正做到这一点.
There's really no reason why you can actually do this.
我唯一的猜测是它允许您覆盖静态方法,但您不能.
My only guess was that it would allow you to override static methods, but you can't.
如果您尝试以下场景:
Banana 有一个名为 'test' 的静态方法(打印出 'banana')Apple 扩展了 Banana 并覆盖"了名为test"的静态方法(这会打印apple")
Banana has a static method called 'test' (this prints 'banana') Apple extends Banana and "overrides" the static method called 'test' (this prints 'apple')
然后你做这样的事情:
public static void main(String[] args) {
Apple apple = new Apple();
Banana banana = new Banana();
Banana base = new Apple();
apple.test();
banana.test();
base.test();
}
结果输出为:
apple
banana
banana
如此有效,却毫无用处.
So effectively, it's pretty useless.