I am woindering why this method
public V get(Object key) {
is not
public V get(K key) {
Thank you
I am woindering why this method
public V get(Object key) {
is not
public V get(K key) {
Thank you
The key may not strictly be of the type K. As long as the equals method contract is followed, any Object could be the key:
More formally, if this map contains a mapping from a key
kto a valuevsuch that (key==null ? k==null : key.equals(k)), then this method returns v; otherwise it returns null. (There can be at most one such mapping.)