Encountering the static method cannot hide instance method from object may be due to the following reasons.

There are 10 requirements for a subclass to override the method of the parent class, two of which are

1. The subclass cannot use a static method to override the non-static method of the parent class. You are making this mistake. It has nothing to do with the protected keyword

2. Similarly, subclasses cannot use non-static methods to override the static methods of the parent class

1, 2 That is to say, if the subclass needs to override the method of the parent class, it is either static or non-static.

Another point is that although you did not make this mistake, you should also be careful
that the code access rights of your parent class are protected, and the subclass will be public after rewriting it, so there is definitely no problem

, but pay attention, the subclass overrides the parent class method, the access permission of the subclass method >= the access permission of the parent class method

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325798138&siteId=291194637