Javatpoint Logo
Javatpoint Logo

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

Test it Now

Output:

size of map before clearing: 6
Map after calling clear(): {}
size of map after clearing: 0

Example 2

Test it Now

Output:

Map : {20=php, 10=Java, 11=.net, 12=C, 30=C++}
keySet : [20, 10, 11, 12, 30]
Map Size  : 5





Youtube For Videos Join Our Youtube Channel: Join Now

Feedback


Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA