需要一些帮助...
我需要找出特定接口(interface)扩展的接口(interface)或( super
接口(interface)名称)
假设我有三个接口(interface) I1、I2、I3。 I1 扩展了 I2 和 I3。一个类,MyClass 扩展了 I1。
在Java中使用Reflections,我可以获得I1,但是如何获得I1扩展的接口(interface),即I2和I3。
请发送一些代码来查找 super 接口(interface)名称。即 I2 和 I3
提前致谢...
最佳答案
你可以做同样的事情 - 正如我假设的 - 你已经为你的类(class)做了同样的事情:
I1.class.getInterfaces();
来自 JavaDoc:
If this object represents an interface, the array contains objects representing all interfaces extended by the interface.
请注意,这将是直接扩展的接口(interface),因此如果 I1 扩展 I2 并且 I2 扩展 I3,那么您必须多次调用该方法。
关于Java - 如何查找由特定接口(interface)或 super 接口(interface)名称扩展的接口(interface),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25503697/