FYI - there's a potential defect there - keys are not required to be strings so you should lookup the value before you cast.
for(Map.Entry<K, V> entry : map.entrySet()){
System.out.println(entry.getKey());
System.out.println(entry.getValue());
}