Java ConcurrentHashMap mappingCount() MethodThe mappingCount() method of ConcurrentHashMap class returns the number of mappings. The value returned is an estimated value; the actual count may differ if there are concurrent insertions or removals. SyntaxParameterNo parameter is passed. Returnsthe number of mappings ThrowsNo exception is thrown. Example 1Test it NowOutput: size of map before clearing: 6 Map after calling clear(): {} size of map after clearing: 0 Example 2Test it NowOutput: Map : {20=php, 10=Java, 11=.net, 12=C, 30=C++} keySet : [20, 10, 11, 12, 30] Map Size : 5
Next TopicJava ConcurrentHashMap
|