문제

Today I realized that calling super.foo() is possible not only inside an overriding foo method, but also inside completely unrelated methods:

class Base
{
    void foo()
    {
    }
}

class Derived extends Base
{
    void foo()
    {
    }

    void bar()
    {
        super.foo();    
    }
}

Is there any real-world scenario, Design Pattern or whatever where this is actually useful?

도움이 되었습니까?

해결책

This would be helpful when a child class wants to provide more meaningful names to a method than the parent class, or providing additional information about the operation in the method name.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top