package reflect;
import java.lang.reflect.Method;
public class Demo1 {
public static void main(String[] args) {
try {
Class cls = Class.forName("reflect.Aoo");
// 创建对象
Object object = cls.newInstance();
// System.out.println(object);
//动态获取类的方法信息
Method[] methods = cls.getDeclaredMethods();
for(Method method:methods){
System.out.println(method.getReturnType());
System.out.println();
if (method.getName().startsWith("test")) {
System.out.println(method.getName());
method.invoke(object);
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
}