File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Class.forName() 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 » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Class.forName()" Watch "Class.forName()" New topic


Krishna Srinivasan
Ranch Hand

Joined: Jul 28, 2003
Posts: 1844

can anyone explain me about the use of Class.forName() method.
Advance Thanx.

Krishna Srinivasan
Spring Tutorials, OCAJP Mock Questions, 400+ OCPJP Mock Questions
Marlene Miller
Ranch Hand

Joined: Mar 05, 2003
Posts: 1391
Here are three of the four ways to get the Class object of a type.
Marlene Miller
Ranch Hand

Joined: Mar 05, 2003
Posts: 1391
Here is a program from Cay Horstmann's Core Java Volume I Chapter 5.
When you are studying Threads, or Strings or the wrapper classes, and you want a list of all the methods, run this program.
>ReflectionTest Thread
You enter a class name and Cay uses forName to get the class object. Once he has the class object, he inquires about all the members of the class.

You can modify it, if you do not want to see the fields or the private members.
[ October 13, 2003: Message edited by: Marlene Miller ]
I agree. Here's the link:
subject: Class.forName()
Similar Threads
An JDBC problem
what this method do in JDBC?
Dynamically loading a class
How to connect MySQL DB from JSP?
JDBC connectivity