You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
19 lines
591 B
19 lines
591 B
|
|
public class Main {
|
|
/**
|
|
* 涓绘柟娉曪紝鐢ㄤ簬娴嬭瘯宸ュ巶鏂规硶妯″紡
|
|
*
|
|
* @param args 鍛戒护琛屽弬鏁?
|
|
*/
|
|
public static void main(String[] args) {
|
|
// 创建具体工厂实例
|
|
Creator creator = new ConcreteCreator();
|
|
|
|
// 调用工厂的操作方法,该方法会使用工厂方法创建产品并调用产品的操作
|
|
creator.someOperation();
|
|
|
|
// 直接使用工厂方法创建产品
|
|
Product product = creator.factoryMethod();
|
|
product.operation();
|
|
}
|
|
} |