package jichengdemo; /* * 写了一个简单的继承demo ,student继承person,通过代码练习发现,父类里面不能有构造方法 */ public class JiChengDemo { public static void main(String[] args) { student s = new student(); s.setname("lixinghua"); s.setage(89); s.setschool("清华大学"); System.out.println(s.getname()+s.getage()+s.getschool()); } } class person{ private String name; private int age; public void setname(String name){ this.name =name; } public void setage(int age){ this.age = age; } public String getname(){ return this.name ; } public int getage(){ return this.age; } } class student extends person{ //student 类继承person的属性和方法; private String school ; public void setschool(String school){ this.school = school; } public String getschool(){ return this.school ; } }