Method这个类代表方法的抽象。
获取方法(只能获取public的),包括继承来的
// 获取方法(只能获取public的),包括继承来的
Method[] methods = aClass.getMethods();
for (Method method : methods) {
logger.debug("public方法 {}", method);
}
结果如下
public方法 public java.lang.String com.nextyu.study.reflection.MyObject.toString()
public方法 public java.lang.String com.nextyu.study.reflection.MyObject.getName()
public方法 public void com.nextyu.study.reflection.MyObject.setName(java.lang.String)
public方法 public void com.nextyu.study.reflection.MyObject.setAge(java.lang.Integer)
pub