(class B extends A) 怎么解释?A是上一个类名
而且编译出来的class文件中是B.class 而不是B.extends A.class.为什么?请教!----------------解决方案--------------------------------------------------------
B继承A
----------------解决方案--------------------------------------------------------
b is a class
没明白为什么要写成你那样
----------------解决方案--------------------------------------------------------
以下是引用chengsencs在2006-7-25 22:25:21的发言:
而且编译出来的class文件中是B.class 而不是B.extends A.class.为什么?请教!
说得再清楚点儿就好了
----------------解决方案--------------------------------------------------------
就是B继承A
----------------解决方案--------------------------------------------------------
哦,多谢!是类的继承。
源码:
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;
}
}
----------------解决方案--------------------------------------------------------