ARTICLE AD BOX
In Java, having two interfaces:
public interface SomeAbstractResult {} public interface SomeInterface { Collection<SomeAbstractResult> someMethod(); SomeAbstractResult someMethod2(); }I want to have concrete implementation of these interfaces like this:
public class SomeConcreteResult implements SomeAbstractResult{} public class SomeClass implements SomeInterface { SomeConcreteResult abc; Collection<SomeConcreteResult> xyz; @Override public Collection<SomeAbstractResult> someMethod() { return this.xyz; //this doesn't work } @Override public SomeAbstractResult someMethod2() { return this.abc; // this works fine } }The problem is that compiler says:
incompatible types: Collection<SomeConcreteResult> cannot be converted to Collection<SomeAbstractResult>
Why is this the case?
