package incheir;
public class i3 extends i2{
private String deparetment;
private String specialiay;
public i3()
{
super("hu",21); //父类的构造函数必须在第一行;
System.out.println("子类有构造方法!");
}
}
package incheir;
public class i2 {
public String name;
public String sex;
public int age;
public i2()
{
System.out.println("父类无构造方法!");
}
public i2(String n,int a)
{
name=n;
age=a;
System.out.println("父类有构造方法!");
}
public void setName(String name) {
this.name = name;
}
public void setSex(String sex) {
this.sex = sex;
}
public void setAge(int age) {
this.age = age;
}
public String getName() {
return name;
}
public String getSex() {
return sex;
}
public int getAge() {
return age;
}
}
package incheir;
public class i1 {
public static void main(String[] args) {
i3 s=new i3();
}
}