import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; public class Example { public static void main(String[] args) { ConcurrentMapmap = new ConcurrentHashMap<>(); map.put("A", 1); map.put("B", 2); map.put("C", 3); System.out.println("Map before clearing: " + map); map.clear(); System.out.println("Map after clearing: " + map); } }
Map before clearing: {A=1, B=2, C=3} Map after clearing: {}The java.util.concurrent package is a part of the Java Concurrency API, which provides a set of classes and interfaces that help developers create multithreaded applications.