Pomóż mi proszę, aby nie przetestować, dlaczego nie mogę wywołać metody testSuper()? Wystąpił błąd kompilacji:Bez limitu symboli wieloznacznych z rozszerzonymi i super jako parametrami
The method testSuper(Group<? super BClass<?>>) in the type Group <BClass<String>> is not applicable for the arguments (Group<AClass<String>>)
Ale metoda testExtends() jest OK. Jednak wygląda to tak samo.
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 not applicable for the arguments (Group<AClass<String>>)
instGrB.testSuper(instGrA);
}
}
Dzięki za odpowiedź, ale co jeśli wezwanie instGrB.testSuper (instGrB)? BClass to typ BClass >. –
Z moimi zmianami, linia ta się kompiluje. – rgettman
tak, kompiluje :) Pytanie jest dlaczego nie kompiluje się z instGrB.testSuper (instGrB), jeśli BClass jest typem BClass >? A może nie? –