wood burning stoves
The moose likes Java in General and the fly likes Object Creation Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Object Creation " Watch "Object Creation " New topic

Object Creation

siva prakash
Ranch Hand

Joined: Aug 24, 2004
Posts: 80
Hi All,

i am going thru specification of java, and i found we can also create an instance of class using Class.forName(class_name).newInstance()

what advantage we can get using this approach instead of normal approach.

pls clarify me

With regards,
M Beck
Ranch Hand

Joined: Jan 14, 2005
Posts: 323
with this way, you don't have to know the class name at compile time. see also the reflection tutorial for more information.
William A White
Ranch Hand

Joined: Jul 01, 2004
Posts: 35
If you don't know what kind of object you want to create, this code lets you decide at run time.

You'd usually make use of it in conjunction with reflection, or some kind of factory that made different objects.
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
subject: Object Creation
jQuery in Action, 3rd edition