Online Java Compiler By
JavaTpoint.com
//import statement import java.util.concurrent.ConcurrentHashMap; import java.util.*; import java.util.function.BiFunction; public class ConcurrentHashMapcomputeExample1 { public static void main(String[] args) { Map
chm = new ConcurrentHashMap
(); //put is used to add value to map chm.put("1", "1"); chm.put("2", "10"); chm.put("3", "100"); chm.put("4", "2"); chm.put("5", "20"); chm.put("6", "200"); System.out.println("Values in map with detail: \n" + chm.toString()); chm.compute("6", (key , val) -> val + 100); System.out.println("Map after using compute(): " + chm); } }
Output