class person
{
String name;
int age;
public person(String name,int age)
{
this.name=name;//this指当前类
this.age=age;
}
}
class student extends person
{
public student()
{
//int i=0;
super("zhangsan",30);//调用父类的构造方法。必须放在第一行,不然报错
}
}
class TT {
public static void main(String[] args) {
student s=new student();
System.out.println(s.name+“-------"+s.age);
}
}
|
|