1.

Can You Store The Duplicate Value In Java Hashmap?

Answer»

Yes, you can put duplicate values in HashMap of Java. It ALLOWS duplicate values, that's why when you RETRIEVE all values from the Hashmap by calling values() method it returns a Collection and not Set. Worth noting is that it doesn't RETURN LIST because HashMap doesn't provide any ordering guarantee for key or value.

Yes, you can put duplicate values in HashMap of Java. It allows duplicate values, that's why when you retrieve all values from the Hashmap by calling values() method it returns a Collection and not Set. Worth noting is that it doesn't return List because HashMap doesn't provide any ordering guarantee for key or value.



Discussion

No Comment Found