To add to @subtenante, Java is designed so that Java will always be backwards compatible. Generics disallow puts of the wrong type, as this does not break backwards compatibility. The easy way to make sure that the right key is being used is to do this.
K key = null;
V value = null;
Map<K,V> mapped = new HashMap<K,V>()
.......//set the key and value..........
mapped.put(key, value)
.....
V var = mapped.get(key);
Problem solved.
One more caveat to generics, any child of a class can also be placed into a collection.
Number k= null;
Number v= null;
Map<Number,Number> mapped = new HashMap<Number,Number>()
.......//set the key and value..........
k = double someDouble;
v = int someInt;
mapped.put(k, v)
.....
This could cause some big bugs!!