随笔分类 -  设计模式

摘要:import com.google.common.collect.Lists;import org.springframework.beans.BeansException;import org.springframework.boot.CommandLineRunner;import org.sp 阅读全文
posted @ 2022-06-04 18:21 剑阁丶神灯 阅读(25) 评论(0) 推荐(0) 编辑
摘要:/** 懒汉式 volatile 防止指令重排序 1 分配空间 2 引用赋值 3 初始化操作 */public class LazySingleton { private static volatile LazySingleton lazySingleton; private LazySinglet 阅读全文
posted @ 2022-06-04 06:34 剑阁丶神灯 阅读(37) 评论(0) 推荐(0) 编辑
摘要:package com.example.SpringBootTest1.shejimoshi.singleton;public class HungrySingleton { private static final HungrySingleton hungrySingleton = new Hun 阅读全文
posted @ 2022-06-04 06:32 剑阁丶神灯 阅读(32) 评论(0) 推荐(0) 编辑
摘要:public class ObserveTest { public static void main(String[] args) { NotifyObject1 notifyObject1 = new NotifyObject1(); NotifyObject2 notifyObject2 = n 阅读全文
posted @ 2022-03-14 11:54 剑阁丶神灯 阅读(8) 评论(0) 推荐(0) 编辑
摘要:public class TemplateMethodTest { public static void main(String[] args) { AbstractClass abstractClass = new Subclass1(); abstractClass.operation(); / 阅读全文
posted @ 2022-03-08 17:13 剑阁丶神灯 阅读(24) 评论(0) 推荐(0) 编辑
摘要:public class StrategyTest { public static void main(String[] args) {// Zombie zombie = new FlagZombie(); Zombie zombie = new BigHeadZombie(); zombie.d 阅读全文
posted @ 2022-03-08 14:26 剑阁丶神灯 阅读(18) 评论(0) 推荐(0) 编辑
摘要:public class WrapperTest { public static void main(String[] args) { /** 拍照 */// Componnet conCreateComponnet = new ConCreateComponnet();// conCreateCo 阅读全文
posted @ 2022-02-25 15:00 剑阁丶神灯 阅读(17) 评论(0) 推荐(0) 编辑
摘要:/** * 建造者 */public abstract class Builder { // 地基 public abstract void buildA(); // 钢筋工程 public abstract void buildB(); // 粉刷 public abstract void bui 阅读全文
posted @ 2022-02-25 13:34 剑阁丶神灯 阅读(29) 评论(0) 推荐(0) 编辑
摘要:******************************************正确写法******************************************************package com.example.SpringBootTest1.shejimoshi.sin 阅读全文
posted @ 2022-02-25 13:34 剑阁丶神灯 阅读(42) 评论(0) 推荐(0) 编辑
摘要:// *****************************现象描述******************************* package com.example.SpringBootTest1.shejimoshi.singleton;public class InnerclassSi 阅读全文
posted @ 2022-02-25 13:33 剑阁丶神灯 阅读(70) 评论(0) 推荐(0) 编辑
摘要:public enum EnumSingleton { INSTANCE;} public class Test { public static void main(String[] args) { EnumSingleton instance1 = EnumSingleton.INSTANCE; 阅读全文
posted @ 2022-02-25 13:33 剑阁丶神灯 阅读(7) 评论(0) 推荐(0) 编辑
摘要:/** * 建造者 */public abstract class Builder { public abstract Builder buildA(String s); public abstract Builder buildB(String s); public abstract Builde 阅读全文
posted @ 2022-02-25 13:33 剑阁丶神灯 阅读(22) 评论(0) 推荐(0) 编辑
摘要:对象适配器模式(组合模式) public class AdapterTest { public static void main(String[] args) { Target target = new Adapter(new Adaptee()); target.output5v(); }}cla 阅读全文
posted @ 2022-02-25 11:15 剑阁丶神灯 阅读(16) 评论(0) 推荐(0) 编辑
摘要:public class System1 { public void dosomething() { System.out.println("system1.."); }} public class System2 { public void dosomething() { System.out.p 阅读全文
posted @ 2022-02-24 23:00 剑阁丶神灯 阅读(16) 评论(0) 推荐(0) 编辑
摘要:public class TreeNode { private Integer x; private Integer y; private Tree tree; public TreeNode(Integer x, Integer y, Tree tree) { this.x = x; this.y 阅读全文
posted @ 2022-02-24 22:31 剑阁丶神灯 阅读(25) 评论(0) 推荐(0) 编辑
摘要:浅拷贝 @Datapublic class ShopItem implements Cloneable { private String shopItemName; public ShopItem clone() throws CloneNotSupportedException { ShopIte 阅读全文
posted @ 2022-02-24 21:26 剑阁丶神灯 阅读(23) 评论(0) 推荐(0) 编辑
摘要:public class InnerclassSingleton { private InnerclassSingleton() {}; private static class Singleton { private static final InnerclassSingleton i = new 阅读全文
posted @ 2022-01-20 16:43 剑阁丶神灯 阅读(29) 评论(0) 推荐(0) 编辑