继承
package com.andy.base.oop.demo01.demo05;
//学生 is 人 : 派生类,子类
//子类继承了父类,就会拥有父类的全部方法!
public class Student extends Person{
//ctrl + h
}
package com.andy.base.oop.demo01.demo05;
//在java中,所有的类,都默认直接或间接继承object
// Person 人 : 父类
public class Person {
private int money = 10_0000_0000;
public void say(){
System.out.println("说了一句话");
}
public int getMoney() {
return money;
}
public void setMoney(int money) {
this.money = money;
}
}
/*
public static void main(String[] args) {
Student student = new Student();
student.say();
}
*/
package com.andy.base.oop.demo01;
import com.andy.base.oop.demo01.demo05.Student;
public class Application {
public static void main(String[] args) {
Student student = new Student();
student.say();
}
}
标签:继承,money,void,base,andy,Student,public
From: https://www.cnblogs.com/zhongjianYuan/p/17162404.html