Java 通过反射获取父类和子类的所有方法
作者:互联网
public final class ReflectionUtils {
public static Method getDeclaredMethod(Object object, String methodName, Class<?> ... parameterTypes){
Method method = null ;
for(Class<?> clazz = object.getClass() ; clazz != Object.class ; clazz = clazz.getSuperclass()) {
try {
method = clazz.getDeclaredMethod(methodName, parameterTypes) ;
return method ;
} catch (Exception e) {
}
}
return null;
}
}
标签:null,Java,子类,Object,clazz,Method,methodName,父类,method 来源: https://blog.csdn.net/fd2025/article/details/119135158