Java tutorial
//package com.java2s; import java.util.*; public class Main { public static <T> Integer changeValue(Map<T, Integer> map, T key, int value) { Integer integer = map.get(key); if (integer != null) { integer += value; map.put(key, integer); } return integer; } }