为了在接口中实现所有方法,我创建了一个实现接口的抽象类,然后让其他类扩展抽象类并仅覆盖所需的方法.
我正在为我的应用程序构建API / Framework.
我想将作为IMyInterface接口实例的类添加到ArrayList:
ArrayList<Class<IMyInterface>> classes = new ArrayList<>(); classes.add(MyClass.class);
这是MyClass
class MyClass extends AbstractIMyInterface {}
这是AbstractIMyInterface
class AbstractIMyInterface implements IMyInterface {}
到目前为止这似乎不可能.我上面的方法不起作用:
add (java.lang.class<com.app.IMyInterface>)
in ArrayList cannot be applied to
(java.lang.class<com.myapp.plugin.plugin_a.MyClass>)
解决方法
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。