Online Java Compiler By
JavaTpoint.com
import java.util.concurrent.*; public class ConcurrentHashMapcomputeIfAbsentExample2 { public static void main(String[] args) { ConcurrentHashMap
mapcon = new ConcurrentHashMap<>(); mapcon.put("alfabets", 26); mapcon.put("digits", 9); mapcon.put("vowels", 5); System.out.println("ConcurrentHashMap values :\n " + mapcon.toString()); mapcon.computeIfAbsent("consonent", k -> 21); System.out.println("new ConcurrentHashMap after computeIfAbsent :\n " + mapcon); } }
Output