why cant we override a base class method with private extended class method?
问题 class One { void foo() { } } class Two extends One { private void foo() { /* more code here */ } } Why is the above snippet of code wrong? 回答1: I'm going to try to incorporate the ideas from the other answers to come up with a single answer. First off, let's take a look at what's going on in the code. A look at the code The One class has a package-private foo method: class One { // The lack of an access modifier means the method is package-private. void foo() { } } The Two class which