ERROR - The method computeIfPresent(String, BiFunction) in the type Map is not applicable for the arguments (String, String)

Error

The method computeIfPresent(String, BiFunction<? super String,? super String,? extends String>) in the type Map<String,String> is not applicable for the arguments (String, String)

Error Type

Compile Time ( Java 8 )

Sample Code

Map<String,String> intMap = new HashMap<String,String>();
intMap.put("Key1","Value1");
intMap.put("Key2", "Value2");
intMap.computeIfPresent("Key1","Value1");   

Cause

The method computeIfPresent expects the second argument as the Function and not the String. 

Resolution

Specify the function as the second argument.

intMap.computeIfAbsent("Key3", (k,v)->v+k);