你可以忽略像这样的方法
for(Method method: clazz.getMethods()) {
if(method.getDeclaringClass() == Object.class) continue;
}
Run Code Online (Sandbox Code Playgroud)
注意:这将包括在子类中重写的方法.
如果您不想要任何继承的方法,您可以使用
for(Method method: clazz.getDeclaredMethods()) {
Run Code Online (Sandbox Code Playgroud)