public static void main(String[] args) throws Exception {
Class<?> cl = SeatVo.class;
//通过getMethods方法获取所有public修饰的普通方法
Method[] methods = cl.getMethods();
for (Method i : methods) {
System.out.println("public修饰的普通方法=" + i.getName());
}
System.out.println();
//通过getDeclaredMethods返回类中所有的实例方法
Method[] methods1 = cl.getDeclaredMethods();
for (Method i : methods1) {
System.out.println("实例方法=" + i.getName());
}
//返回public修饰的所有属性
Field[] fields = cl.getFields();
for (Field f : fields) {
System.out.println("public修饰的所有属性=" + f.getName());
System.out.println("public修饰的所有属性中文=" + f.getAnnotation(ApiModelProperty.class).value());
}
//返回本类中的所有属性
Field[] fieldList = cl.getDeclaredFields();
for (Field f : fieldList) {
System.out.println("返回本类中的所有属性=" + f.getName());
System.out.println("返回本类中的所有属性中文=" + f.getAnnotation(ApiModelProperty.class).value());
}
}