Li Wu:
Learn to think more, honouring teachers save Thanksgiving. Leaf See root Three return one, living water Qingyuan hidden in zero.
Meekness The Lord of Conscience, Haoyuedangkong the King of Freedom. Willing to give the most ascetic no regrets, sincere advice and the line and cherish.
Os:windows7 x64
Jdk:jdk-8u131-windows-x64
Ide:eclipse Oxygen Release (4.7.0)
Package blog.jizuiku7;/** * Template design mode * Here is just to provide a simple implementation, understanding the spirit is good, to work ingenious only good. * * @author Jizuiku * @version V17.10.03 */pu Blic abstract class Abstractreadsomething {/* * provide a specific template, the application only need to change the steps of the changes therein * * reading this process, to the most bitter hypothesis reading has three steps, came to the desk, reading, leaving the desk * three steps , the only thing that can change is the act of reading. Read the Analects today and read the Moral sutra tomorrow. Read Maths today and read Chinese tomorrow! * So reading this action should be changed to abstract method, in the specific sub-class should be required to make the transformation. */public void Readbook () {System.out.println ("Come to the desk"); Read (); System.out.println ("Leave the desk"); public abstract void Read ();
Package blog.jizuiku7;/** * * * @author Jizuiku * @version V17.10.03 */public class Readchinesebook extends Abstra ctreadsomething {@Overridepublic void read () {//TODO auto-generated method StubSystem.out.println ("read Chinese book");}
Package blog.jizuiku7;/** * Template design pattern -specific implementation subclass * * @author Jizuiku * @version V17.10.03 */public class Readmathbook E Xtends abstractreadsomething {@Overridepublic void read () {//TODO auto-generated method StubSystem.out.println ("read math book") ;}}
Test class
Package blog.jizuiku7;/** * Demo Template design mode use * * @author Jizuiku * @version V17.10.03 */public class Demo {public static V OID Main (string[] args) {abstractreadsomething Arsmath = new Readmathbook (); Arsmath.readbook (); System.out.println (); abstractreadsomething Arschinese = new Readchinesebook (); Arschinese.readbook ();}}
Results
Java is good, worth learning.
The design pattern contains extremely high intelligence, which is helpful to project development.
Learning resources: Itcast and Itheima Video library. If you have public resources, can share to me, with your resources to learn also can.
Blog post is to watch the video, into thinking written. It's good that the teacher speaks well. Blog bad, is to give the most bitter not serious.
Java Basic template mode