Hashtable the same key with a different value ....?

Is it possible with java, the hash table can display the same keys for different values? .. How can I get both values ​​from hashtable ...

+3
source share
2 answers

you cannot unless you save the key value as a list of values.

take a look at Google Multimap: http://google-collections.googlecode.com/svn/trunk/javadoc/index.html?com/google/common/collect/Multimap.html

+8
source

You cannot do this, all keys on a Hash or Hash Table card must be unique.

Then you need to consider another collection

+1
source

Source: https://habr.com/ru/post/1780599/


All Articles