File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
Java in General
Joined: Aug 24, 2004
Jun 07, 2005 12:13:00
i am going thru specification of
, 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
Joined: Jan 14, 2005
Jun 07, 2005 12:32:00
with this way, you don't have to know the class name at compile time. see also the
for more information.
William A White
Joined: Jul 01, 2004
Jun 07, 2005 12:35:00
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.
subject: Object Creation
My interview questions
Batch Delete Problem
Best way to search for an element in integer array
Running java program from another java program
executeUpdate() returning unexpected results
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2014