Why doesn't Java allow hiding static methods by instance methods?

后端 未结 4 2046
旧时难觅i
旧时难觅i 2021-02-20 03:25

As shown in http://docs.oracle.com/javase/tutorial/java/IandI/override.html, Java does allow

  1. Overriding an instance method by an instance method and
  2. Hidin
4条回答
  •  醉话见心
    2021-02-20 04:19

    Simple answer: that would be the mess.

    Concrete answer: what to call in that case Derived.foo()? Base.foo() can't be called as it's hidden (as per you), Derived.foo() can't be called as it's not static.

提交回复
热议问题