import java.util.HashMap;
import java.util.Map;
public class MyClass
{
public static<K> void IncrementMapValue(Map<K, Integer> map, K key) {
map.putIfAbsent(key, 0);
map.put(key, map.get(key) + 1);
}
public static void main(String[] args)
{
Map<String, Integer> hm = new HashMap();
hm.put("Java", 1);
hm.put("python", 2);
IncrementMapValue(hm, "Java");
IncrementMapValue(hm, "python");
IncrementMapValue(hm, "rust");
System.out.println(hm);
}
}
/*
run:
{Java=2, rust=1, python=3}
*/