JAVA单例模式有哪些?
单例模式的俩种方式:饿汉式class Singleton { private static Singleton instance=new Singleton(); private Singleton(){} static Singleton getInstance() { return instance; }}懒汉式class Singleton { private static Singleton instance=null; private Singleton(){} static Singleton getInstance() { if(instance==null) instance=new Singleton(); return instance; }}