反射获取类对象:
获取Class类对象的三种方法:
package com.gao.reflect;
public class Demo1 {
public static void main(String[] args) throws Exception {
//方法一:forname获取类对象
Class c = Class.forName("com.gao.reflect.Student");
System.out.println(c);
//方法二:类名.class
Class c1 = Student.class;
System.out.println(c1);
//方法三:对象名.getclass
Student student= new Student();
Class c2 = student.getClass();
System.out.println(c2);
}
}