可以考虑使用静态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!");
}
} |