下面的代码对我来说完全有意义 - 它是关于添加某种类型的元素,该类型是T类型的超类型,而S类型绝对是这样的超类型,那么为什么编译器拒绝将“element”添加到集合中呢?
class GenericType<S,T extends S>{
void add1(Collection<? super T> col ,S element ){
col.add(element); // error
// The method add(capture#9-of ? super T) in the type
// Collection<capture#9-of ? super T> is not applicable for the arguments (S)
}
}