标签:静态工厂和实例工厂
静态工厂:工厂初始化之前,工厂中的类已经被实例化放在工厂容器中public class StaticFactory {
public static void main(String[] args) {
Object bean = StaticFactory.getBean();
}
public static Object getBean(){
return new Object();
}
}
实例工厂:工厂在构造方法初始化时,会将类进行实例化放在工厂中
class InstanceFactory {
public static void main(String[] args) {
InstanceFactory factory = new InstanceFactory();
Object bean = factory.getBean();
}
public Object getBean(){
return new Object();
}
}
标签:静态工厂和实例工厂
原文地址:http://blog.51cto.com/13579086/2087951