标签:
classPerson{
String name;
int age;
void introduce(){
System.out.println("我的名字是:"+ name +",我的年龄是:"+ age);
}
}
classStudent extends Person{
String address;
void introduce(){
//System.out.println("我的名字是:" + name + ",我的年龄是:" + age);
super.introduce();
System.out.println("我的家在"+ address);
}
}
classTest{
publicstaticvoid main(String args []){
Student s =newStudent();
s.name ="张三";
s.age =18;
s.address ="北京";
s.introduce();
Person p =newPerson();
p.name ="李四";
p.age =22;
p.introduce();
}
}
标签:
原文地址:http://www.cnblogs.com/arroneve/p/5815437.html