I am storing a contact list as a HashMap of type "Person", and want to have a search feature where I can search the HashMap and then return all people of the first name "John" and who live in the USA, for example. My idea is to just create an ArrayList of Person and loop through add each value as such:

```
  Map<Person, Person> hm = new HashMap<Person, Person>();
  ArrayList<String> result = new ArrayList<String>();

  Enumeration num= hm.keys();
  String name = "John";
  String location = "USA"; 

  while (num.hasMoreElements()) {
         Person person = (Person) num.nextElement();

         if(person.name.equals(name) && person.location.equals(location))
         {
            result.add(person);
         }

```

I was just wondering if this would work okay or if there is some better way of doing this that I've overlooked.

Thanks