I am new to generics and I would appreciate any help I can get with the following problem:
I have this parent class:
public class Parent<K, V> {
public void f(K key,V value){}
}
And then I have this child class:
public class Child<K,V> extends Parent<K,LinkedList<V>> {
@Override
public void f(K key,V value) {}
}
Well, the hope was that Child.f
would override Parent.f
, but unfortunately the compiler doesn't like what is going on here and gives me:
Name clash: The method f(K, V) of type Child<K,V> has the same erasure as f(K, V) of type
Parent<K,V> but does not override it
I have seen this error before in different contexts, but I am not sure why it comes up in this particular one. Is there any way of avoiding it?
Thanks in advance.