I'm trying to extend the HashMap class to accept multiple values per key. I'd like .put(key,value) to put a single key/value pair. I'd like .get(key) to return a Vector<V> of all the values associated with key, and .get(key, index) to return a single value of type V for that key. I am using Eclipse 3.2 and Java 1.5.
The problem I am having is my .put(K key,V value) method won't compile, I get the error:
Name clash: The method put(K,V) of type OneToManyHashMap<K,V> has the same erasure as put(K,V> of type HashMap<K,V> but does not override it
My code (roughly):
public class OneToManyHashMap<K,V> extends HashMap<K, Vector<V>> {
public V get(Object key, int index) { return get(key).get(index); }
public V put(K key, V value) { ... }
public V remove(Object key, int index) { return get(key)
}
Yes, I know there is an extra > in the code. It's wasn't there when I typed the message and it's not there when I try and edit the message to remove it :(
Message was edited by:
jiggersplat