gpt4 book ai didi

java - 查找类中定义的接口(interface)

转载 作者:行者123 更新时间:2023-11-29 07:48:53 25 4
gpt4 key购买 nike

如何使用 Apache BeanUtilsMethodUtils 等查找类中定义的所有可用接口(interface)?

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

最佳答案

我怀疑你只是想要 Class.getClasses() :

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(),然后使用Class.isInterface过滤掉非接口(interface).

关于java - 查找类中定义的接口(interface),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22938852/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com