• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Printing HashMap!

 
Joseph John
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
I have created an array of HashMaps with the following values:
HashMap map[0] = new HashMap;
map[0].put("SSN", "999999999");
map[0].put("FNAME", "XYZ");
map[0].put("LNAME", "ABC");
map[0].put("ADDRESS", "123");
HashMap map[1] = new HashMap;
map[1].put("SSN", "1234567890");
map[1].put("FNAME", "DEF");
map[1].put("LNAME", "GHI");
map[0].put("ADDRESS", "456");
and so on..
I am trying to test my code so that when the user searches by SSN or LNAME or by both, it searches through all the maps
and returns the matching map. However, I am having trouble getting the map to be printed. How do I do it?
Here is a part of my test code:
input.put("SSN","1234567890");
Map retMap = (Map) result.getResponse();
printMap(retMap);

input.put("LNAME","");
retMap = (Map) result.getResponse();
printMap(retMap);

input.put("SSN","");
input.put("LNAME","");
retMap = (Map) result.getResponse();
printMap(retMap);
//private void printMap(Map map)
//{
//}
 
Tim Blommerde
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear Joseph John,
Too be honest, I do not completely grasp your intentions, nor do I understand what you are trying to do with the code part you provided. But if you're looking for a way to print a HashMap, like you stated in the title of your post, all you have to do is use the toString() method.

Good luck,
Tim
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic