Error
The method computeIfAbsent(String, Function<? 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.computeIfAbsent("Key3", "Value1");
Cause
The method computeIfAbsent expects the second argument as the Function and not the String.
Resolution
Specify the function as the second argument.
intMap.computeIfAbsent("Key3", e->e.concat("ComputedValue"));
The method computeIfAbsent(String, Function<? 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.computeIfAbsent("Key3", "Value1");
Cause
The method computeIfAbsent expects the second argument as the Function and not the String.
Resolution
Specify the function as the second argument.
intMap.computeIfAbsent("Key3", e->e.concat("ComputedValue"));