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

后端 未结 4 2110
旧时难觅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:11

    Another to add here is: 1. Static methods belong at the class level. So u cannot override method in the derived class. as simple its called hiding. :) 2. Instance methods belong to the objects, so objects are overrided. So we can override in the derived class.

    Above other comments give a good example have a look into it..

    Regards Punith

提交回复
热议问题