java - 如何调用祖父类中被覆盖的方法?
怪我咯
怪我咯 2017-04-17 15:33:36
0
1
360
public class one
{
    public void hello()
    {
        System.out.println("one");
    }
}

public class two extends one
{
    @Override
    public void hello()
    {
        System.out.println("two");
    }
}

public class three extends two
{
    @Override
    public void hello()
    {
        //如何调用one中的hello方法
    }
}

怎么在three()中调用one的方法了,突然想到了这个问题,google了以后发现没有好的方法或者说是无法实现,这里应该是不能调用super关键字来实现的,java初学者.

怪我咯
怪我咯

走同样的路,发现不同的人生

répondre à tous(1)
黄舟

答案是 不行

你的这个期望的实现非常奇怪,你可能要重新考虑你的程序结构的设计

类就是对具有相同特征的一类事务所做的抽像,如果你的three子类不具备two父类的特征,那它本来就不应该成为这个two父类的子类,而应该成为one子类的

Derniers téléchargements
Plus>
effets Web
Code source du site Web
Matériel du site Web
Modèle frontal
À propos de nous Clause de non-responsabilité Sitemap
Site Web PHP chinois:Formation PHP en ligne sur le bien-être public,Aidez les apprenants PHP à grandir rapidement!