Override “private” method in java

后端 未结 5 1080
小蘑菇
小蘑菇 2020-11-27 16:18

There something ambiguous about this idea and I need some clarifications.

My problem is when using this code:

public class B {

    private void don(         


        
5条回答
  •  死守一世寂寞
    2020-11-27 17:00

    No, a private method cannot be overridden since it is not visible from any other class. You have declared a new method for your subclass that has no relation to the superclass method. One way to look at it is to ask yourself whether it would be legal to write super.func() in the Derived class.

提交回复
热议问题