摘要:
再构造方法里面判断单例是否存在,存在则抛出异常 阅读全文
posted @ 2022-07-25 23:41
dronff
阅读(27)
评论(0)
推荐(0)
摘要:
再类中添加一个readResolve方法(非静态),方法直接返回单例对象 阅读全文
posted @ 2022-07-25 23:37
dronff
阅读(43)
评论(0)
推荐(0)
摘要:
饿汉式 -方式一 public class SingletonTest { private SingletonTest(){} private static SingletonTest instance = new SingletonTest(); public static SingletonTe 阅读全文
posted @ 2022-07-25 23:23
dronff
阅读(26)
评论(0)
推荐(0)
摘要:
阅读全文
posted @ 2022-07-25 23:10
dronff
阅读(12)
评论(0)
推荐(0)
摘要:
public class SingletonTest { private static volatile SingletonTest singletonTest; public static SingletonTest getInstance(){ if(singletonTest == null) 阅读全文
posted @ 2022-07-25 23:04
dronff
阅读(69)
评论(0)
推荐(0)
摘要:
开闭原则 开闭原则规定"软件中的对象(类,模块,函数等等)应该对于扩展是开放的,但是对于修改是封闭的" 抽象接口 public interface AbstractTheme { void printColor(); } public class RedTheme implements Abstra 阅读全文
posted @ 2022-07-25 20:08
dronff
阅读(35)
评论(0)
推荐(0)

浙公网安备 33010602011771号