diff --git a/src/main/java/com/msb/templateMethod/Main.java b/src/main/java/com/msb/templateMethod/Main.java new file mode 100644 index 0000000..670bd6e --- /dev/null +++ b/src/main/java/com/msb/templateMethod/Main.java @@ -0,0 +1,43 @@ +package com.msb.templateMethod;/** + * @Author bingor + * @Date 2022/10/19 9:47 + * @Description: com.msb.templateMethod + * @Version: 1.0 + */ + +/** + *@ClassName Main + *@Description TODO + *@Author bingor + *@Date 2022/10/19 9:47 + *@Version 3.0 + */ +public class Main { + public static void main(String[] args) { + Father father = new Child(); + father.exe(); + } +} + +abstract class Father { + public void exe() { + opt1(); + opt2(); + } + + public abstract void opt1(); + public abstract void opt2(); +} + +class Child extends Father { + + @Override + public void opt1() { + System.out.println("child:opt1"); + } + + @Override + public void opt2() { + System.out.println("child:opt2"); + } +}