继承
继承
//java中所有的类,都默认继承直接或者间接继承object
//Person :人 父类
//java中只有单继承没有多继承
public class Person {
private int money = 10_0000_0000;
public int getMoney() {
return money;
}
public void setMoney(int money) {
this.money = money;
}
public void say(){
System.out.println("说话");
}
}
===================================================================
//子类继承父类的所有属性
public class Student extends Person{
}
===================================================================
public class Application {
public static void main(String[] args) {
Student student = new Student();
student.say();
System.out.println(student.getMoney());
}
}