首页 > 代码库 > Java单例模式

Java单例模式

package singleton;
/**
 * 单例模式
 * @author pengYi
 *
 */
public class Singleton {

	private static Singleton instance = null;
	
	private Singleton(){}
	
	public static Singleton getSingletonInstance(){
		if (instance == null) {
			instance =  new Singleton();
			return instance;
		} else {
			return instance;
		}	
	}
}

  

Java单例模式