请帮我解释为什么我不能调用testSuper()方法?有编译错误:
The method testSuper(Group<? super BClass<?>>) in the type Group <BClass<String>> is not applicable for the arguments (Group<AClass<String>>)
Run Code Online (Sandbox Code Playgroud)
但testExtends()方法OK.但是,它看起来一样.
class AClass<T> {}
class BClass<T> extends AClass<T> {}
class Group<T> {
T name;
public void testExtends(Group<? extends AClass<?>> value){}
public void testSuper(Group<? super BClass<?>> value){}
public T getName(){return name;}
}
public class GenericTest {
public static void GenericTestMethod(){
Group<AClass<String>> instGrA = new Group<AClass<String>>();
Group<BClass<String>> instGrB = new Group<BClass<String>>();
//OK
instGrA.testExtends(instGrB);
//The method testSuper(Group<? super BClass<?>>) in the type Group <BClass<String>>
//is …Run Code Online (Sandbox Code Playgroud)