Results 1 to 3 of 3
- 05-06-2010, 07:26 PM #1
Member
- Join Date
- May 2010
- Posts
- 2
- Rep Power
- 0
- 05-07-2010, 04:45 AM #2
You have more problems than that if you think this is a Swing/AWT question. Or is it that you can't be bothered to put in the effort to post in the correct subforum?
db
- 05-07-2010, 04:51 AM #3
Member
- Join Date
- May 2010
- Posts
- 2
- Rep Power
- 0
Class.forName(...).newInstance() is a way of creating an instance of a class at runtime using the Java Reflection API. Here is an example:
String className = ""java.util.Vector";
Class cls = Class.forName(className);
List list = (List)cls.newInstance();
The cls.newInstance() calls the default constructor to create a new instance of the class.
Normally you would use reflection when you want to determine the implementation at runtime instead of at compile time. This is the main concept behind Dependency Injection. You define interfaces and provide the implementation of the interface at runtime through some configuration.
I hope this answers your question.
Similar Threads
-
class.forName(" ");
By srikantha in forum Advanced JavaReplies: 2Last Post: 08-13-2009, 01:23 PM -
Class.forName Exception
By Moncleared in forum Advanced JavaReplies: 5Last Post: 02-21-2009, 06:08 AM -
failure at Class.forName("oracle.jdbc.driver.OracleDriver");
By RonNYC in forum EclipseReplies: 1Last Post: 03-14-2008, 02:51 PM -
about Class.forName
By angus203 in forum New To JavaReplies: 0Last Post: 11-25-2007, 04:47 AM -
question about Class.forName()
By oregon in forum JDBCReplies: 4Last Post: 08-01-2007, 04:52 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks