private int age;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getSex() {
return sex;
}
public void setSex(String sex) {
this.sex = sex;
}
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
public void work()
{
System.out.println("我是你爹");
}
}
public class TestZhangsan {
public static void main(String[] args) {
Zhangsan z=new Zhangsan();
z.setName("张三");
z.setSex("男");
z.setAge(20);
System.out.println("名字:"+z.getName()+"性别:"+z.getSex()+"年龄:"+z.getAge());
z.work();
System.out.println();
Lisi l=new Lisi();
l.setName("李四");
l.setSex("女");
l.setAge(21);
System.out.println("名字:"+l.getName()+"性别:"+l.getSex()+"年龄:"+l.getAge());
l.work();
}
public class Lisi extends Zhangsan {
public Lisi(){
System.out.println("你是我爹");
}
}