Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
Win a copy of
Android Security Essentials Live Lessons
this week in the
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.
I agree. Here's the link:
subject: Object Creation
Running java program from another java program
My interview questions
executeUpdate() returning unexpected results
Batch Delete Problem
Best way to search for an element in integer array
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2014