获得类的信息
1.获得类的名字
Class clazz=Class.forName("com.cn.test")
clazz.getName();
clazz.getSimpleName();
2.获得类的属性
Field[] f1=clazz.getFields();
Field[] f2=clazz.getDeclaredFields();
3.获得制定属性的值
Field[] name = clazz.getDeclaredField("name")
4.获得类的方法
Method[] m1=clazz.getMethods();
Method[] m2=clazz.getDeclaredMethods();
Method m3=clazz.getMethods("testName",null);
Method m4=clazz.getMethods("testName",
5.获得构造器
与获取类方法类似:把Method换成Constructor即可
例:
clazz.getDeclaredConstructor(String.Class,int.Class,int.Class);