Is it possible with java that a hashtable can map the same keys to different values? .. How can I retrieve both value from hashtable...
Asked
Active
Viewed 2.7k times
4
-
Duplicate, see http://stackoverflow.com/questions/4456280/need-help-mapping-this-data-in-java/4456312#4456312 – andersoj Dec 16 '10 at 05:13
-
Got Similar error when using TF 1 ```tf.contrib.lookup.index_table_from_file(vocabulary_file="vocab_file.txt")```. Error was ```FailedPreconditionError: HashTable has different value for same key.``` The issue was input Vocab_file.txt had duplicate data. – sakeesh Aug 26 '21 at 04:14
2 Answers
8
you cannot, unless you store the key's value as a list of values.
take a look at google's Multimap: http://google-collections.googlecode.com/svn/trunk/javadoc/index.html?com/google/common/collect/Multimap.html

The Scrum Meister
- 29,681
- 8
- 66
- 64
-
Yes, and a search of SO with tag multimap reveals a lot of insight on this. http://stackoverflow.com/questions/tagged/multimap?sort=votes&pagesize=50 – andersoj Dec 16 '10 at 05:17