Java问题,不懂,求大神解析,问题如下:
classSuper{publicvoidm1(){System.out.println("m1()inSuper");}publicvoidm2(){System.ou...
class Super{
public void m1(){
System.out.println("m1() in Super");
}
public void m2(){
System.out.println("m2() in Super");
}
}
class Sub extends Super{
public void m1(){
System.out.println("m1() in Sub");
super.m1();
}
public void m2(){
super.m1();
}
}
public class T1{
public static void main(String args[]){
Sub s=new Sub();
s.m1();
s.m2();
}
}
为什么这句
public void m2(){
super.m1();
}
引用不了m1,求解析! 展开
public void m1(){
System.out.println("m1() in Super");
}
public void m2(){
System.out.println("m2() in Super");
}
}
class Sub extends Super{
public void m1(){
System.out.println("m1() in Sub");
super.m1();
}
public void m2(){
super.m1();
}
}
public class T1{
public static void main(String args[]){
Sub s=new Sub();
s.m1();
s.m2();
}
}
为什么这句
public void m2(){
super.m1();
}
引用不了m1,求解析! 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询