摘要:
从一道很古老的面试题说起 public class TestString { public static void main(String[] args) throws InterruptedException { String a = new String("abc"); String b = n 阅读全文
摘要:
单例模式,顾名思义,就是全局只保存有一个实例并且能够避免用户去手动实例化,所以单例模式的各种写法都有一个共同点,不能通过new关键字去创建对象,因此,如果能够通过构造方法实例化,那么就一定要将其声明为私有。 饿汉式 public class PersonResource { public stati 阅读全文