如:
class GrandPa
{
    void Method()
    {
        System.out.println("Hello, I am GrandPa!");
    }
}
class Father extends GrandPa
{
    void Method()
    {
        System.out.println("Hello, I am Father!");
    }
}
class Son extends Father
{
    void Method()
    {
        // 如何调用GrandPa的Method?        super.Method();
    
        System.out.println("And Son is followed!");
    }
}

解决方案 »

  1.   

    除了在Son类的Method中用:GrandPa g = new GrandPa();  g.Method(); 以外
    还有什么更好的方法?因为如果GrandPa是抽象类的话,这招就不灵了。
      

  2.   

    oh man, you could define your father class like this
    class Father extends GrandPa
    {
        void Method()
        {
            System.out.println("Hello, I am Father!");
        }
        void methodAgain()
        {
            super.Method();
            System.out.println("Hello, I am Father!");
        }
    }so, in the sub-sub-class you will invoke like this:        super.methodAgain();    
            System.out.println("And Son is followed!");it will never, ever affect the father class nor the top class.i thing u get it, huh?my regards
      

  3.   

    我认为如果你的设计里如果要孙子辈的类访问爷爷,那设计也就是有问题的了,类继承结果该修改了,也学son,father都作grandpa的子类更合适
      

  4.   

    sorry,结构。。也许。。好多错别字
      

  5.   

    楼主可以考虑使用静态static方法class GrandPa
    {
        static void Method()
        {
            System.out.println("Hello, I am GrandPa!");
        }
    }
    class Father extends GrandPa
    {
        static void Method()
        {
            System.out.println("Hello, I am Father!");
        }
    }
    class Son extends Father
    {
        static void Method()
        {
            GrandPa.Method();// 这样可以调用GrandPa的Method        Father.Method();
        
            System.out.println("And Son is followed!");
        }
    }
      

  6.   

    看看gemouzhi(gemouzhi) 的例子
      

  7.   

    看看gemouzhi(gemouzhi) 的例子
    很好的解释
      

  8.   

    你要在Father 中有可以条用爷爷类的方法,否则不行的,不过方法还是有的,因为人是活的
      

  9.   

    这种问题不合逻辑,毫无意思
    因为是多态,你只能知道你的父类,根本不应该和父类的父类有任何牵连.我要调用Object的toString()方法怎么办?
    有点自相毛度
      

  10.   

    gemouzhi(gemouzhi)的方法或是static方法都能够实现。