有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java查找类中定义的接口

如何使用ApacheBeanUtilsMethodUtils等查找类中定义的所有可用接口

public class MyClass() {
   .....
   public interface Interface1{};
   public interface Interface2{};
}

共 (1) 个答案

  1. # 1 楼答案

    我猜你只是想^{}

    Returns an array containing Class objects representing all the public classes and interfaces that are members of the class represented by this Class object. This includes public class and interface members inherited from superclasses and public class and interface members declared by the class. This method returns an array of length 0 if this Class object has no public member classes or interfaces. This method also returns an array of length 0 if this Class object represents a primitive type, an array class, or void.

    因此,调用MyClass.class.getClasses(),然后使用^{}过滤掉非接口