I have an issue with the method idTag of Q class. I'm not sure what type should be put instead of XXXX. I've tried < T extends Taggable< T >> but there is an issue with the following call : Q.idTag (b) ;
It says :
The method idTag(List) in the type Q is not applicable for the arguments (ArrayList< RedElem>)
< T extends Taggable< T >> Doesn't seem to be the correct answer but i'm running out of idea, I don't know what could be the right one thank you
interface Taggable<T> {
void tag(T t);
T getTag();
}
class Elem implements Taggable<Elem> {}
class Obj implements Taggable<Obj> {}
class RedElem extends Elem {}
class Q {
static <XXXX> void idTag(List<T> l) {
for (T e : l) e.tag(e);
}
public static void main(String args[]) {
ArrayList<Elem> a = new ArrayList<Elem>();
ArrayList<RedElem> b = new ArrayList<RedElem>();
ArrayList<Obj> c = new ArrayList<Obj>();
idTag(a);
idTag(b);
idTag(c);
}
}