getClass
public final Class getClass()Returns the runtime class of an object. That Class object is the object that is locked by static synchronized methods of the represented class. Returns:
the object of type Class that represents the runtime class of the object.也就是得出类或者实体所继承的父类名
如public class getClass {    public static void main(String[] args) {
        Object b=new Object();
        System.out.println(b.getClass());
        ObjectTest c=new ObjectTest();
        System.out.println(c.getClass());
    }
}
输出
class java.lang.Object
class j2.ObjectTest其中ObjectTest是我自己建的一个类

解决方案 »

  1.   

    为什么显示图片等操作中,要用getClass().getResource()呢?
    我总感觉不太明白。
      

  2.   

    为什么显示图片等操作中,要用getClass().getResource()呢?
    ----------
    可以读取一些配置文件和图片之类的东西
      

  3.   

    Class类的那些方法是不是在从源文件获取类的信息啊?
    既然已经读了,顺便它也读了一下其它的文件。
      

  4.   

    取得一个对象运行时的实际型别的相关信息(存在Class类的一个对象中)的引用!
      

  5.   

    为什么这个类有一个取得类以外的信息的方法叫getResource()呢?
    这个方法和类信息有什么关系?
      

  6.   

    每个类A都包含一个Class实例字段,该实例存放类A的状态信息