나는 ArrayList<Class<? extends IMyInterface>> classes = new ArrayList<>();
을 가지고 있습니다. 나는 그것을 반복 할 때 내가 얻을 :ArrayList를 중개하는 방법 <Class <? extends 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();
}
}
Inconvertible types; cannot cast 'java.lang.Class<capture<? extends com.myapp.IMyInterface>>' to 'com.myapp.IMyInterface'
가 어떻게 그것을 통해 반복에 대해 갈 수 ERROR?
감사합니다. 당신은 IMyInterface
의 특정 메소드를 호출 할로 IMyInterface
의 인스턴스에서 반복 할
당신은'ArrayList>''ArrayList '가 아닙니다. 그리고 그런데, 이것은 당신이 원하는 것이 아닙니다 ...'클래스'는 타입을 나타내는 인스턴스입니다. 타입 자체의 인스턴스는 아닙니다. 그러므로'instanceof IMyInterface'는 결코 사실이 아닙니다. –
AxelH