wushenjiang

 

public class b
{
{
        void show() {
            System.out.println("b");
        }


}
    
public class c extends b
{
    
    void show() {
        System.out.println("c");
    }
    void showc() {
        super.show();
        show();
    }
}
    public static void main(String[] args) {
        
        c x=new c();
        
        x.showc();
        
    }
}

运行结果:

可以看到,要调用子类中与父类同名的方法,要加一个super.就可以了。

分类:

技术点:

相关文章:

  • 2021-09-11
  • 2021-09-05
  • 2021-12-30
  • 2021-07-24
  • 2021-04-13
  • 2021-11-02
  • 2022-02-08
猜你喜欢
  • 2021-07-15
  • 2021-06-13
  • 2021-10-24
  • 2021-05-08
  • 2022-02-22
  • 2021-07-09
  • 2022-01-04
相关资源
相似解决方案