Class对象能够代表被JVM加载进来的所有的类,注意是这些类本身,而不是这些类的实例,通常,对程序员来说,类是产生实例的模板,但对JVM来说,每一个这种模板当然也是一个对象,Class的实例就能代表这种类对象,该类的一些方法就能获得许多关于类的信息,比如某个类的名字,这个类所拥有的方法等等。我觉得能够在运行时获取许多类本身的信息,这是许多编程框架(如struts)实现的基础,。

解决方案 »

  1.   

    java.lang 
    Class Class
    java.lang.Object
      |
      +-java.lang.ClassAll Implemented Interfaces: 
    Serializable --------------------------------------------------------------------------------public final class Class
    extends Object
    implements Serializable
    Instances of the class Class represent classes and interfaces in a running Java application. Every array also belongs to a class that is reflected as a Class object that is shared by all arrays with the same element type and number of dimensions. The primitive Java types (boolean, byte, char, short, int, long, float, and double), and the keyword void are also represented as Class objects. Class has no public constructor. Instead Class objects are constructed automatically by the Java Virtual Machine as classes are loaded and by calls to the defineClass method in the class loader. The following example uses a Class object to print the class name of an object: 
         void printClassName(Object obj) {
             System.out.println("The class of "  obj 
                                " is "  obj.getClass().getName());
         }
     
    Since:
    JDK1.0 
      

  2.   

    java.lang是基础类包!!!会被自动强制包含在所有的JAVA中,不过是隐含的!!!其中有很多类,比如:Boolean、Long、Math......等
    所以它是最重要的类!!!