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, (<no type> e) -> e.concat("ComputedValue"))
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",e->e.concat("ComputedValue"));
Cause
The method computeIfPresent expects the second argument as the Function of two arguments.
Resolution
Specify the function with two arguments as the second argument.
intMap.computeIfAbsent("Key3", (k,v)->v+k);
The method computeIfPresent(String, BiFunction<? super String,? super String,? extends String>) in the type Map<String,String> is not applicable for the arguments (String, (<no type> e) -> e.concat("ComputedValue"))
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",e->e.concat("ComputedValue"));
Cause
The method computeIfPresent expects the second argument as the Function of two arguments.
Resolution
Specify the function with two arguments as the second argument.
intMap.computeIfAbsent("Key3", (k,v)->v+k);