Files
javaSE-0419/day09/src/com/inmind/extends01/Demo01.java

27 lines
727 B
Java
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package com.inmind.extends01;
/*
继承的格式和和基本使用
public class Fu{
}
public class Zi extends Fu{
}
继承的特点子类拥有父类的所有内容除了被private和构造方法。
继承的好处:实现多个类中相同内容的复用,子类可以实现各自的不同功能需求!!!!
*/
public class Demo01 {
public static void main(String[] args) {
//创建一个班主任对象
BanZhuRen bzr = new BanZhuRen();
bzr.age = 20;
bzr.name = "张三";
bzr.salary = 5000.0;
bzr.eat();
Teacher teacher = new Teacher();
teacher.age = 20;
teacher.name = "张三";
teacher.salary = 5000.0;
teacher.eat();
}
}