什么是继承
- Java中类只有单继承,没有多继承!(一个儿子只能有一个爸爸,但是一个爸爸可以有多个儿子)
package com.oop.dome05;
public class Person {
public int money = 1_0000_0000;
public void say(){
System.out.println("说了一句话");
}
}
package com.oop.dome05;
public class Student extends Person{
}
package com.oop.dome05;
public class Teacher extends Person{
}
package com.oop;
import com.oop.dome05.Student;
public class Application {
public static void main(String[] args) {
Student student = new Student();
student.say();
System.out.println(student.money);
}
}