• Post Reply Bookmark Topic Watch Topic
  • New Topic

how to retrive values for key in MultiMap  RSS feed

 
malli
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi..

can any one tell me how to retrive values for a given key using MultiMap(

my java code in given below

MultiMap Mp =new MultiHashMap();
Mp.put("1","aaaaaaa");
Mp.put("2","bbbb");
Mp.put("3","ccccc");
Mp.put("1","eeeedddd");
Mp.put("1","aaaggggg");
Mp.put("3","nnaaa");

i want output like 1 aaaaaaa
eeeedddd
aaaggggg
2 bbbb
3 ccccc
nnaaa

Thanks

cheers
Mallik



 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
 
Bill Cruise
Ranch Hand
Posts: 148
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
According to the MultiHashMap API, you need to use the get method to return the collection that is stored at each key. Try this:

List values = Mp.get("1");
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!