2011-05-31 114 views

回答

13

例如,

MyInterfaceOrAbstractClass.class.getDeclaredMethods(); 
+0

+1:这会给你的公共方法。你可以使用getMethod()来获得它的所有方法(你可能需要为父母做这件事:) – 2011-05-31 09:55:18

+0

或Class.getMethods()? – keuleJ 2011-05-31 09:55:40

+3

@Peter,当然你的意思是相反 – 2011-05-31 09:57:23

4
Class clazz = Something.class; 
Method[] methods = clazz.getDeclaredMethods(); 
for (Method method : methods) { 
    // do what you have to do with the method 
    System.out.println(method.getName()); 
}