简单工厂,代码: public interface ISpeak { public void Say(); } public class Hello : ISpeak { public void Say() { //throw new NotImplementedException(); Console.WriteLine("Hello"); } } public class Bye : ISpeak { public void Say() { Console.WriteLine(&q…
1. 使用静态工厂方法创建Bean,用到一个工厂类 例子:一个Car类,有brand和price属性. package com.guigu.spring.factory; public class Car { private String brand; private double price; public Car(){ } public Car(String brand,double price){ this.brand=brand; this.price=price; } public S…