集册 Java实例教程 显式调用基类的构造方法

显式调用基类的构造方法

欢马劈雪     最近更新时间:2020-01-02 10:19:05

535
显式调用基类的构造方法

class Employee {/** 来 自 时代Java - nowjava.com**/

  private String name = "Unknown";


  public Employee(String name) {

    this.name = name; 

  }


  public void setName(String name) {

    this.name = name;

  }


  public String getName() {

    return name;

  }

}

 class Manager extends Employee {
 /* from 
 N  o w  J a v a . c o m*/

  public Manager(String name) {

    super(name);

  }

}



public class Main {

  public static void main(String[] args) {

    Manager mgr = 
展开阅读全文