我有一个ArrayList<Class<? extends IMyInterface>> classes = new ArrayList<>();.当我尝试迭代它时,我得到:
Incopatible types:
Required: java.lang.Class <? extends IMyInterface>
Found: IMyInterface
Run Code Online (Sandbox Code Playgroud)
我的迭代
for (IMyInterface iMyInterface : IMyInterface.getMyPluggables()) {}
Run Code Online (Sandbox Code Playgroud)
红色代码警告突出显示(Android Studio)
Error:(35, 90) error: incompatible types: Class<? extends IMyInterface> cannot be converted to IMyInterface
Run Code Online (Sandbox Code Playgroud)
我想要
ArrayList<Class<? extends IMyInterface>> classes = new ArrayList<>();
for (Class<? extends IMyInterface> myClass : classes) {
if (myClass instanceof IMyInterface) {
View revPluggableViewLL = myClass.getMyInterfaceMethod();
}
}
Run Code Online (Sandbox Code Playgroud)
错误
Inconvertible types; cannot cast 'java.lang.Class<capture<? extends com.myapp.IMyInterface>>' to 'com.myapp.IMyInterface'
Run Code Online (Sandbox Code Playgroud)
我该怎么去迭代呢?
谢谢大家.