浮云间
				直接上一个简单工厂方法案例看一下哈,通过代码解释补充一下,题主问题打的标签是java,以下是php代码,天下代码是一家
// 定义一个接口
interface Person 
{
    public function getWork();
}
// 实现该接口
class Teacher implements Person 
{
    public function getWork()
    {
        echo 'Teacher teaching';
    }
}
class Student implements Person 
{
    public function getWork()
    {
        echo 'Student study';
    }
}
// 此处为核心点
class Factory
{
    /*
      通过静态方法返回生成的指定类的对象
      按照我们的理解,实例化对象需要 new 类名
      如 $test = new Test;
      $test->方法名();
      再实例化一个:
      $test2 = new Test2;
      $test2->方法名();
      ......
      实例化一次就需要再new一次类
      
      而通过此处的简单工厂模式,则可以不需要知道具体的类名就可以生成对象
         
    */
    public static function getPerson($work)
    {
        return new $work;
    }
}
$res = Factory::getPerson('Teacher');
$res->getWork();