日期:2014-05-20  浏览次数:20736 次

调用顶层类方法?
class   A
{
public   void   out()
{
System.out.println( "a ");
}
}
class   B   extends   A
{
public   void   out()
{
System.out.println( "b ");
}
}
class   C   extends   B
{
public   void   out()
{
System.out.println( "c ");
super.out();
}
}
class   W
{
public   static   void   main(String[]   args)
{
C   m=new   C();
m.out();
}
}

输出是:
c
b
很容易理解,因为super.out();可以调用父类的方法。请问如何在C类中调用A类的方法?有没有像super.out();一样的好用的?谢谢

------解决方案--------------------
那用这个可以调用A中的方法:
A n = new A();
n.out();
------解决方案--------------------
没有.
------解决方案--------------------
可以实现就行了,有时假没必要钻牛角尖