简体   繁体   中英

Get all methods of an Interface or Abstract class using Reflection

How can I use reflection on an interface/abstract class to get all of its methods?

Eg,

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM