my dog learned polymorphism
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

Win a copy of Introducing JavaFX 8 Programming this week in the JavaFX forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Printing HashMap!" Watch "Printing HashMap!" New topic

Printing HashMap!

Joseph John

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:
Map retMap = (Map) result.getResponse();

retMap = (Map) result.getResponse();

retMap = (Map) result.getResponse();
//private void printMap(Map map)
Tim Blommerde

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,
I agree. Here's the link:
subject: Printing HashMap!
It's not a secret anymore!