A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
Joined: Nov 21, 2005
Jan 04, 2006 05:47:00
What is the use of class.forName ()
Joined: Dec 01, 2005
Jan 04, 2006 05:52:00
It helps you to instantiate classes dynamically at the runtime
<a href="http://www.goodoldmanoj.blogspot.com/" target="_blank" rel="nofollow">http://www.goodoldmanoj.blogspot.com/</a>
Joined: Oct 18, 2004
Jan 04, 2006 06:30:00
This does not instantiate a class. Rather it load the class with the classloader and returns the
Joined: Sep 16, 2005
Jan 04, 2006 06:43:00
Well, one more step and you are there:
String className = ... read from xml config for example Class cls = Class.forName(className); Object object = cls.newInstance(); //Then, often you cast it to an appropriate interface, and off you go: Runnable r = (Runnable) object; new Thread(r).start();
There is no emoticon for what I am feeling!
With a little knowledge, a
cast iron skillet
is non-stick and lasts a lifetime.
subject: class.forName ()
what this method do in JDBC?
An JDBC problem
How to connect MySQL DB from JSP?
Dynamically loading a class
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2013