package TT.base.oop.Demo5; public class Application { public static void main(String[] args) { Person person=new Person(); } }
====================================
package TT.base.oop.Demo5; //Person人 父类 //在java中,所有的类,都默认直接或者间接继承object类 public class Person { //public //protected //default //private public int money = 10000000; public void say() { System.out.println("说了一句话"); } } //java中只有单继承,没有多继承
===============================
package TT.base.oop.Demo5; //Teacher is Person 派生类 public class Teacher extends Person { }
===============================
package TT.base.oop.Demo5; //学生 is 人 派生类 //子类继承了父类,就会拥有了父类的全部方法! public class Student extends Person{ Person person; } //ctrl+h快捷键