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
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 java.lang.Class object.
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!
I agree. Here's the link:
subject: class.forName ()
An JDBC problem
Dynamically loading a class
what this method do in JDBC?
How to connect MySQL DB from JSP?
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2014