Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    Apr 2007
    Posts
    179
    Thanks
    17
    Thanked 0 Times in 0 Posts

    DocumentBuilderFactory.newInstance(); OR TransformerFactory.newInstance();

    Usually when we create a reference to an class, we'll do:

    Test tst = new Test();

    But when we create a DocumentBuilderFactory or a TransformerFactory, we use:

    DocumentBuilderFactory.newInstance();

    or

    TransformerFactory.newInstance();

    Why use the newInstance() instead?


    Thanks


    Scott

  • #2
    Senior Coder shyam's Avatar
    Join Date
    Jul 2005
    Posts
    1,563
    Thanks
    2
    Thanked 163 Times in 160 Posts
    coz thats the abstract factory design pattern read more here http://en.wikipedia.org/wiki/Abstract_factory_pattern
    You never have to change anything you got up in the middle of the night to write. -- Saul Bellow


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •