常用设计模式

单例模式

   简单描述:确保一个类只有一个实例,并提供一个全局访问点

 

package com.linzhanghui.designpatterns;

public class Singleton {
	private static Singleton uniqueInstance;

	private Singleton() {
	}

	public static Singleton getInstance() {
		if (uniqueInstance == null) {
			uniqueInstance = new Singleton();
		}
		return uniqueInstance;
	}
}

 

常见应用场景:

 

 

工厂模式:

常见应用场景:

 

 

你可能感兴趣的:(设计模式)