62,628
社区成员
发帖
与我相关
我的任务
分享public Person(){
private String name = "Hello"
protected int age = 10;
public void setName(String n){
this.name = n
}
public void getName(){
return this.name
}
}
public Student {
private String ID;
public Student(id){
age = 12; // 继承父类,直接使用
super.setName("aaa"); //无法继承,靠公共方法设置
this.ID = id;
public static void main(String[] args){
System.out.println(getName()) ; // 继承父类,直接使用,返回名字
}
}