开发者

Get all methods of an Interface or Abstract class using Reflection

开发者 https://www.devze.com 2023-03-09 04:53 出处:网络
How can I use ref开发者_如何学编程lection on an interface/abstract class to get all of its methods?E.g.,

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());
}
0

精彩评论

暂无评论...
验证码 换一张
取 消