125
Java ConcurrentHashMap mappingCount() Method
The 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.
Syntax
Parameter
No parameter is passed.
Returns
the number of mappings
Throws
No exception is thrown.
Example 1
Output:
size of map before clearing: 6 Map after calling clear(): {} size of map after clearing: 0
Example 2
Output:
Map : {20=php, 10=Java, 11=.net, 12=C, 30=C++} keySet : [20, 10, 11, 12, 30] Map Size : 5
Next TopicJava ConcurrentHashMap