Saturday, September 25, 2010

To get the object java.lang.Class

By using Class.forName (), we can get in three ways:
  1. Class.forName(“c. test”);
‘C’ object of java.lang.class representing the class test.
  1. By using getClass() of java.lang.Object
Test t=new test ();
Class c=t. getClass ();
Here c is the object java.lang.class representing class test
  1. By using .class keyword
Class c= String .class;
C represents java.lang.String class
Class c=test. Class
C represents java.lang test class

No comments:

Post a Comment