Possible Duplicate:
Java Generics: Why Does Map.get() Ignore Type?
Could someone please explain why with Map defines
V put(K key,V value);
V get(Object key);
Why is get
not defined as:
V get(K key)
Similarly, why are these methods typed to Object
, and not K
and V
respectively?
boolean containsKey(Object key); // Why not K?
boolean containsValue(Object value); // Why not V?
Is this a backwards compatibility thing (pre 1.5)?