나는 또한 인수로 두 List<VersionInterface>
을 받아들이는 방법을 내 객체 ObjectDefinition
인터페이스 매개 변수가있는 메서드는 어떻게 호출합니까?
에 의해 구현되는 인터페이스 VersionInterface
있습니다.
ObjectDefinition
은 VersionInterface
을 구현하므로 내 방법에 두 개의 List<VersionInterface>
을 인수로 전달할 수 없습니다.
방법 정의 :
public List<VersionInterface> updateArtifact(List<VersionInterface> currentCopy, List<VersionInterface> updatedCopy)
ObjectDefinition
정의 :
public class ObjectDefinition implements VersionInterface {
것은 내가 updateArtifact
전화 했어 방법 :
service.updateArtifact(currentCopy, updatedCopy);
currentCopy
및 updatedCopy
모두 ArrayList<ObjectDefinition>
있습니다 내가 얻을 :
The method updateArtifact(List<VersionInterface>, List<VersionInterface>) in the type ORService is not applicable for the arguments (List<ObjectDefinition>, List<ObjectDefinition>)
편집 : 내 문제는 인터페이스가 아닌 서브 클래스
기존 게시물이 질문에 답변한다고 생각합니다. (https://stackoverflow.com/questions/10643443/passing-arraylistsubclass-to-method-declared-with-listsuperclass) –
필자의 예제는 인터페이스를 사용하고 확장을 다루지 않는다. –