摘要: 第九章 Bridge模式 //使用代码 public class Main(){ public static void main(String[] args){ Display d1 = new Display(new StringDisPlayImpl("Hello, China.")); Dis 阅读全文
posted @ 2024-11-04 23:55 大俗XD 阅读(7) 评论(0) 推荐(0)
摘要: 第五章 Singleton 模式 单例模式应该是开发中用的比较多的模式。这里我只记一个知识点。 多线程下安全的单例模式的一个知识点 public class Singleton{ public static InstanceClass instance = null; public static S 阅读全文
posted @ 2024-11-04 18:46 大俗XD 阅读(12) 评论(0) 推荐(0)
摘要: 交给子类 Teamplate Method 模式 -- 将具体任务交给子类 核心代码 public abstract class AbstractDisplay{ public abstract void open(); public abstract void print(); public ab 阅读全文
posted @ 2024-11-04 17:28 大俗XD 阅读(13) 评论(0) 推荐(0)
摘要: 第一章 Iterator模式 -- 一个一个遍历 为什么要使用 Iterator模式? 正常遍历我们使用 for 循环即可,为什么要在集合引入 Iterator 这个角色呢? eg while(it.hasNext()){ Book book = (Book) it.next(); System.o 阅读全文
posted @ 2024-11-04 16:49 大俗XD 阅读(15) 评论(0) 推荐(0)