反射
-
反射获取method 方法
- Method getMethod 根据方法名和参数类型获得对应的方法对象,只能获取public的
- Method getDeclaredMethod 根据方法名和参数类型获取对应方法对象,包括private的
- Method[] getMethods 获取类中成员方法对象,获取public修饰的且包含父类的
- Method[] getDeclaredMethods 获取本类声明的方法(所有的)
-
反射获取属性值
- Field getField() 获取属性值,public修饰的
- Field getDeclaredMethod 获取属性值,包含private的
- Field[] getFields() 获取所有public修饰的属性值
- Field[] getDeclaredMethods 获取所有属性值
-
反射获取构造方法
-
Constructor getConstructor 根据参数获取某个构造器 public 修饰的
-
Constructor getDeclaredConstructor 获取某个声明的构造器
-
Constructor[] getConstructors 获取public修饰的构造器
-
Constructor[] getDeclaredConstructors 获取所有声明的构造器
用途 创建对象
T new Instance(Object … args)
-