Aiutatemi per favore a capire perché non posso chiamare il metodo testSuper()? Errore di compilazione:Caratteri jolly illimitati con extends e super come parametri
The method testSuper(Group<? super BClass<?>>) in the type Group <BClass<String>> is not applicable for the arguments (Group<AClass<String>>)
Ma il metodo testExtends() OK. Tuttavia, sembra lo stesso.
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);
}
}
Grazie per la risposta, ma cosa succede se chiamata instGrB.testSuper (instGrB)? BClass è un tipo di BClass >. –
Con le mie modifiche, quella linea ora viene compilata. – rgettman
sì, compila :) La domanda è perché non si compila con instGrB.testSuper (instGrB), se BClass è un tipo di BClass >? O no? –