The java.util.concurrent.ConcurrentHashMap.size() method is an in-built function in Java which counts the number of key-value mappings in this map and returns the integer value.
public int size()
Return Value: The function returns an integer value which denotes the number of key-value mappings in this map.
Below program illustrate the use of size() method :
The number of key-value mappings is 3
The number of key-value mappings is 6
Attention reader! Don’t stop learning now. Get hold of all the important Java Foundation and Collections concepts with the Fundamentals of Java and Java Collections Course at a student-friendly price and become industry ready. To complete your preparation from learning a language to DS Algo and many more, please refer Complete Interview Preparation Course.