标签:增加 ring img ima 技术 err stat image 单一职责
1.基本概念
2.代码实现
package com.chengjie; interface Product1 { void show(); } interface Factory1 { Product1 createProduct(); } class ProductA1 implements Product1 { @Override public void show() { System.out.println("ProductA1.show() is called!"); } } class ProductB1 implements Product1 { @Override public void show() { System.out.println("ProductB1.show() is called!"); } } class FactoryA implements Factory1 { @Override public Product1 createProduct() { return new ProductA1(); } } class FactoryB implements Factory1 { @Override public Product1 createProduct() { return new ProductB1(); } } public class TestFactoryMethod { public static void main(String[] args) { FactoryA fa = new FactoryA(); fa.createProduct().show(); FactoryB fb = new FactoryB(); fb.createProduct().show(); } }
3.优点
4.缺点
5.应用场景
6.参考链接
https://www.jianshu.com/p/d0c444275827
标签:增加 ring img ima 技术 err stat image 单一职责
原文地址:https://www.cnblogs.com/forTheDream1991/p/10436235.html