Get all methods of an Interface or Abstract class using Reflection
How can I use ref开发者_如何学编程lection on an interface/abstract class to get all of its methods?
E.g.,
MyInterfaceOrAbstractClass.class.getDeclaredMethods();
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());
}
精彩评论