在子类中,若要调用父类中被覆盖的方法,可以使用super关键字

在子类中,若要调用父类中被覆盖的方法,可以使用super关键字。

package text;

class Parent
{
    int x;
    public Parent()
    {
        
            System.out.println("Parent Created1");
      }
    public void show(){
        System.out.println("Parent Created2");
    }

}



class Child extends Parent
{
    int y;
    public Child()
     {
    
        System.out.println("Child Created1");

      }
    public void show(){
        super.show();
        System.out.println("Parent Created3");
    }

}



public class text
{


    public static void main(String args[])
     {

            Child c = new Child();
    c.show();
  }

}

原文地址:https://www.cnblogs.com/liushiqiang123/p/7816787.html