aspose file tools*
The moose likes Beginning Java and the fly likes Class.forName(thisclass) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Class.forName(thisclass)" Watch "Class.forName(thisclass)" New topic
Author

Class.forName(thisclass)

Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
Can anyone gives me explanation about forName()?
When is forName() used for?
Dirk Schreckmann
Sheriff

Joined: Dec 10, 2001
Posts: 7023
monang,
Welcome to JavaRanch!
We ain't got many rules 'round these parts, but we do got one. Please change your display name to comply with The JavaRanch Naming Policy.
Thanks Pardner!


[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
Bosun Bello
Ranch Hand

Joined: Nov 06, 2000
Posts: 1506
It is a static member of the 'Class' class. Forname() gives you a reference to the 'Class'class. It takes a string containing the name of the class you want a reference for loads the class.


Bosun (SCJP, SCWCD)
So much trouble in the world -- Bob Marley
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
Originally posted by monang:
Can anyone gives me explanation about forName()?
When is forName() used for?

Class.forName() is used to reference classes you don't want to have a compile time dependency to - for example because you don't know which actual class to use before runtime.


The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Class.forName(thisclass)
 
Similar Threads
ClassNotFoundException
creating dynamic object
JDBC Connection Class
calling java inside a servlet
What does Class.forName do?