(class B extends A) 怎么解释?A是上一个类名
而且编译出来的class文件中是B.class 而不是B.extends A.class.为什么?请教!
说得再清楚点儿就好了
哦,多谢!是类的继承。
源码:
class StudentTest
{
public static void main(String[] args)
{
Student aStudent = new Student();
aStudent.setName("张楠");
aStudent.setStudentNum("20030408");
System.out.println("学生的姓名是:" + aStudent.getName() + ",学号是:" + aStudent.getStudentNum());
}
}
class People
{
private String name;
public String getName(){
return name;
}
public void setName(String strName)
{
name = strName;
}
}
class Student extends People
{
private String studentNum;
public String getStudentNum()
{
return studentNum;
}
public void setStudentNum(String strStudentNum)
{
studentNum = strStudentNum;
}
}