aspose file tools*
The moose likes Beginning Java and the fly likes Printing HashMap! Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Printing HashMap!" Watch "Printing HashMap!" New topic
Author

Printing HashMap!

Joseph John
Greenhorn

Joined: Oct 03, 2001
Posts: 1
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

Joined: Sep 24, 2001
Posts: 21
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
 
Don't get me started about those stupid light bulbs.
 
subject: Printing HashMap!