反射之Class对象获取的三种方式
package com.bjsxt.text;
public class TestClass {
public static void main(String[] args) throws ClassNotFoundException {
/**
* 获得Class对象的三种方式
*
*/
//1.通过字节码文件获取
Class c1= Integer.class;
//2.通过对象的getName()获取
Class c2 = c1.getClass();
//3.通过Class类的静态方法获取
Class c3 = Class.forName("com.bjsxt.text.TestClass");
System.out.println(c1);
System.out.println(c2);
System.out.println(c3);
}
}