/*inherit 1, improve the reusability of code, simplify the code 2, let the class and the class has an inheritance relationship, only the existence of the characteristics of the later polymorphism note: Do not want to get other classes to simplify the code, and to establish an inheritance relationship, you must have the class and the class has an inheritance relationship, inheritance relationship: is a ( If something is a kind of something, for example, a cat is a cat family. 3, the subclass has a member of the parent class 4, the subclass can not have the parent class in the private decorated member 5, Java support multi-layered inheritance in multi-layer inheritance in the hierarchy of the sub-class has the entire inheritance system members, The top-level parent class defines the generality of all subclasses. Java does not support multiple inheritance, only support single inheritance, because multiple inheritance is a security hazard (this multi-inheritance is not a multi-layered inheritance, but a class does not support inheriting multiple classes) when more than one parent class defines the same member, the subclass object is not sure which one to run. Java preserves this mechanism and uses it in another way (multiple implementations)*///Parent class, Super class, base classclassporson{String name; intAge ;}//sub-classclassStudentextendsporson{voidStuby () {System.out.println (Learning); }}//sub-classclassTeatherextendsporson{voidTeath () {System.out.println (Teaching); }} Public classtest{ Public Static voidMain (string[] args) {}}/*English extension: Porson: Man student: Student Teather: Teacher*/
JAVA Inheritance extends