I am trying to build a class that implements Queue
and Map
. Both interfaces define the remove(Object)
method, but with different return types:
public interface Collection<E> { //Queue extends Collection, which has the problem method
public boolean remove(Object e);
//...
}
public interface Map<K,V> {
public V remove(K key);
//...
}
public class QueuedMap<K,V> extends AbstractMap implements Queue {
public V remove(K key) {/* ... */}
//ERROR: V is not compatible with boolean
//...
}
The type erasure of K is causing these two method signatures to collide. I can't have one of them because it's an invalid override, and I can't have both because they have the same signature. Is there any way that I can make these two interfaces coexist?