The method:
public static void incrementMapCounter( Map<Object,Number> tabulationMap, Object key ) {
Number value = 0;
if ( tabulationMap.containsKey(key) ) {
value = tabulationMap.get(key);
}
value = value.doubleValue() + new Double(1);
tabulationMap.put( key, value );
}
Call to the method:
Map<String,Long> counts = new HashMap<>();
String key = "foo-bar";
incrementMapCounter( counts, key );
Error (reformatted):
The method
incrementMapCounter(Map<Object,Number>, Object)
in ... is not applicable
for the arguments (Map<String,Long>, String)
The method signature is either a matching type or more generic:
- Map is a Map
- String is an Object (x2)
- Long is a Number
I'm a bit confused on this one.