Online Java Compiler By
JavaTpoint.com
import java.util.concurrent.ConcurrentHashMap; import java.util.*; public class ConcurrentHashMapclearExample1 { 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: \n" + chm); chm.clear(); // clear will clear all the values in map. System.out.println("Map after calling clear(): " + chm); } }
Output