@@ -0,0 +1,1009 @@
+package creational;%0A%0A/**%0A * Created by %E6%9D%8E%E6%81%92%E5%90%8D on 2017/6/14.%0A * %3Cp%3E%0A * %E5%B7%A5%E5%8E%82%E6%96%B9%E6%B3%95%E6%A8%A1%E5%BC%8F%0A */%0Apublic class FactoryMethodPattern %7B%0A%0A    public static void main(String%5B%5D args) %7B%0A        CarFactory factory = new BenzFactory();%0A        //CarFactory factory = new BMWFactory();%0A        Car car = factory.getCar();%0A        car.run();%0A    %7D%0A%0A    static abstract class Car %7B%0A        abstract void run();%0A    %7D%0A%0A    static class Benz extends Car %7B%0A%0A        @Override%0A        void run() %7B%0A            System.out.println(%22%E5%A5%94%E9%A9%B0%E8%BD%A6%E5%9C%A8%E8%B7%91%22);%0A        %7D%0A    %7D%0A%0A    static class BMW extends Car %7B%0A%0A        @Override%0A        void run() %7B%0A            System.out.println(%22%E5%AE%9D%E9%A9%AC%E8%BD%A6%E5%9C%A8%E8%B7%91%22);%0A        %7D%0A    %7D%0A%0A    static abstract class CarFactory %7B%0A        abstract Car getCar();%0A    %7D%0A%0A    static class BenzFactory extends CarFactory %7B%0A        @Override%0A        Car getCar() %7B%0A            return new Benz();%0A        %7D%0A    %7D%0A%0A    static class BMWFactory extends CarFactory %7B%0A        @Override%0A        Car getCar() %7B%0A            return new BMW();%0A        %7D%0A    %7D%0A%7D%0A%0A

add > 工厂方法模式