Java的单例模式与延时加载

Java的单例模式与延时加载,讲解的非常好

java单例模式与延时加载


附上代码:

public class Singleton {

	private Singleton() {
	}

	private static class SingletonHolder{
		static Singleton instance =  new Singleton();
	}
	
	public Singleton getInstance(){
		return SingletonHolder.instance;
	}
	
}


你可能感兴趣的:(java,Singleton)