我无法得到这个编译,我看不出原因。 最终,我想传递一个对象的集合,这些对象的类将TClass扩展到生成方法中,该方法需要类扩展TClass的对象的集合,这应该起作用。有界的Java的泛型不编译
任何帮助,将不胜感激。
public interface Generator<IT extends ITClass, T extends TClass> {
IT generate(Collection<T> tClassCollection)
}
Generator<?, ? extends TClass> generator = generatorClass.newInstance();
Collection<? extends TClass> TClassCollection = ...
... generator.generate(TClassCollection);
我得到这个错误
The method generate(Collection<capture#8-of ? extends TClass>) in the type
Generator<capture#7-of ?,capture#8-of ? extends TClass> is not applicable for the arguments (Collection<capture#9-of ? extends TClass>)
ITClass是否实施/扩展自Collection或Collection extends T>? –
Raze
2011-06-09 10:40:12