【发布时间】:2018-12-06 03:42:46
【问题描述】:
public class SS {
public static void main(String[] args) {
SS s = new SS();
List<B> list = new ArrayList<>();
s.checkWithoutInheritance(Arrays.asList(new B())); //Works fine
s.checkWithoutInheritance(list); //----------Not working
s.checkWithInheritance(Arrays.asList(new B())); //Works fine
s.checkWithInheritance(list); //Works fine
}
private void checkWithInheritance(final Collection<? extends A> s) {
}
private void checkWithoutInheritance(final Collection<A> s) {
}
}
class A {
};
class B extends A {
};
【问题讨论】:
标签: java generics inheritance collections