import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
public class demo {
public static void main(String[] args) throws ClassNotFoundException, NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException {
Class<?> c = Class.forName("javase.day22.demo01.Student");
Method[] methods = c.getDeclaredMethods();
//Method[] methods = c.getMethods();
for (Method method : methods) {
System.out.println(method);
}
System.out.println("----------");
Method m = c.getMethod("method1");
//获取无参构造方法创建对象
Constructor<?> con = c.getConstructor();
Object obj = con.newInstance();
m.invoke(obj);
}
}