关于子类父类继承的问题,代码无错误,为什么运行没有结果啊。
请各位帮忙看看。
class Person{
String name;
char sex;
Person(){}
Person(String s,char c){
name=s;
sex=c;
}
public void setName(String s) {
name=s;
}
public void setSex(char c) {
sex=c;
}
public String getName() {
return name;
}
public char getSex() {
return sex;
}
public void show() {
System.out.println(name+","+sex);
}
}
class Student1 extends Person{
int studentNumber;
Student1(){}
Student1(String s,char c,int n){
super(s,c);
studentNumber=n;
}
public void setStudentNumber(int n) {
studentNumber=n;
}
public int getstudentNumber() {
return studentNumber;
}
public void show() {
super.show();
System.out.println(","+studentNumber);
}
}
public class Sy15_7 {
public static void main(String[]args) {}{
Student1 s1=new Student1();
s1.setName("张三");
s1.setSex('男');
s1.setStudentNumber(202101);
s1.show();
Student1 s2=new Student1("王五",'女',202102);
s2.show();
}
}