效果是一样的,不同的是,  getInstance可以动态的创建一个实例

解决方案 »

  1.   

    new每次都会产生一个新的对象
    getInstance每次取到同一个对象
      

  2.   

    "new" is bound to create one new object
    "newInstance()" gives you flexibility. you can do straight "new", get an object from a pool, call some other factory, or return singleton. In short, it is one indirection.class X implements IX{...}"new X" promises to the client that you are giving back nothing but an instance of X
    "IX newInstance()" does not promise that much. you can give back anything that implements IX. this gives you much more flexibility in design.