Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Archive
Java
Creating funny objects
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
[QUOTE="Michael Borgwardt, post: 592762"] This is known as a factory method. Paul gave an example why one might want to do this. Basically, it's more flexible than a constructor, because a constructor can only "return" an instance of the concrete class, while a factory can declare an abstract class or an interface as its return type and return an arbitrary subclass or intrface implementation. Note that in your code, SAXParser is an abstract class, so it's not possible to instantiate it with "new". No. The factory method will use "new" in some way, directly or indirectly. [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
Java
Creating funny objects
Top