私はArrayList<Class<? extends IMyInterface>> classes = new ArrayList<>();
を持っています。私はそれを反復処理しようとすると、私が手:ArrayList <class <?をインターラートする方法IMyInterface >>
Incopatible types:
Required: java.lang.Class <? extends IMyInterface>
Found: IMyInterface
マイ反復
for (IMyInterface iMyInterface : IMyInterface.getMyPluggables()) {}
レッドコード警告ハイライト(アンドロイドスタジオ)
Error:(35, 90) error: incompatible types: Class<? extends IMyInterface> cannot be converted to IMyInterface
私は
したいですArrayList<Class<? extends IMyInterface>> classes = new ArrayList<>();
for (Class<? extends IMyInterface> myClass : classes) {
if (myClass instanceof IMyInterface) {
View revPluggableViewLL = myClass.getMyInterfaceMethod();
}
}
ERROR
Inconvertible types; cannot cast 'java.lang.Class<capture<? extends com.myapp.IMyInterface>>' to 'com.myapp.IMyInterface'
どのように私はそれを反復処理については行くことができますか?
ありがとうございます。あなたはIMyInterface
の特定のメソッドを呼び出すしたいとIMyInterface
のインスタンスで反復処理したい
あなたは 'ArrayList> 'ではなく、' ArrayList 'を継承します。ところで、これはあなたが望むものではありません... 'Class'は型を表すインスタンスであり、その型自体のインスタンスではありません。したがって、 'instanceof IMyInterface'は決して真実ではありません。 –
AxelH