2011-05-31 23 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()); 
}