1 Answers
How many objects will be there inside the HashMap in Java?
In a Java HashMap, the number of objects inside the map will depend on the number of key-value pairs that have been inserted into the map. Each key-value pair counts as one object in the HashMap.
If there are n key-value pairs inserted into the HashMap, then the total number of objects inside the HashMap will be n.
It is important to note that the HashMap does not allow duplicate keys, so each key in the map must be unique. However, the values associated with the keys can be duplicates.
Please login or Register to submit your answer