| 12345678910111213141516171819202122232425262728293031323334353637383940 |
- package course;
- /**
- * @author WanJl
- * @version 1.0
- * @title MyOneDayTemplate
- * @description
- * @create 2026/7/23
- */
- public abstract class MyOneDayTemplate {
- /*
- 一般 模板类分为两部分:
- 1、 1个是使用final修饰的不能被重写的,只能被调用的 方法
- 方法里面一般是执行步骤。
- 2、 另1个是使用abstract修饰的需要被重写的方法
- */
- /**
- * 只能使用,不能修改
- */
- public final void myOneDay(){
- System.out.print("《我的一天》");
- System.out.print("今天我吃了");
- this.eat();
- System.out.print("然后我又");
- this.sleep();
- System.out.print("最后我又玩了");
- this.play();
- System.out.print("好开心哟~");
- System.out.println();
- }
- public abstract void eat();
- public abstract void sleep();
- public abstract void play();
- }
|