import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
//暴力反射使用私有方法
public class ReflectDemo3 {
public static void main(String[] args) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException {
Class<Student> studentClass = Student.class;
Constructor<Student> declaredConstructor = studentClass.getDeclaredConstructor(String.class);
//暴力反射,强行使用私有构造器
declaredConstructor.setAccessible(true);
Student student = declaredConstructor.newInstance("郭奉孝");
System.out.println(student);
}
}