• Post Reply Bookmark Topic Watch Topic
  • New Topic

java  RSS feed

 
phani kon
Ranch Hand
Posts: 251
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a problem with hashtable. Is it posssible to add no of values to the same key. If so, Could please give me some examples

for example:

hashtable.put("one",aa);
hashtable.put("one",bbb));


thanks
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

What you want is called a "MultiMap", and there's no implementation of one in the Java APIs. You can instead add a List (for example, a LinkedList or ArrayList) under the desired key, then add the objects to that array list.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!