当前位置: 首页 > 图灵资讯 > 技术篇> 继承的使用

继承的使用

来源:图灵教育
时间:2023-05-29 14:02:33

public class extendemo1 {    public static void main(String[] args) {       coder c=new coder();       c.setName(张三);       c.setAge(23);       c.setSalary(13000);        System.out.println(c.getName()+"--"+c.getAge()+"--"+c.getSalary());    }}class Employee{    private String name;    private int age;    private double salary;    public String getName() {        return name;    }    public void setName(String name) {        this.name = name;    }    public int getAge() {        return age;    }    public void setAge(int age) {        this.age = age;    }    public double getSalary() {        return salary;    }    public void setSalary(double salary) {        this.salary = salary;    }}class coder extends Employee{}class manager extends Employee{