Why doesn't this work?
public class FooImpl implements Foo { /* ... */ }
public class Main {
public static <T> Collection<T> getList(Class<? extends T> itemClass) { /* ... */ }
public static void main(String[] args) {
Collection<Foo> foos = getList(FooImpl.class);
}
}
On the line where foos
is declared, I'm getting "Incompatible types. Required: Collection<Foo>, found: Collection<FooImpl>
" error. Any idea why?