How does the following method work?
Pairs is a LinkedHashMap, I am just not sure of the enhanced for loop and how it works with the hasmap. i.e the keyset.
/**
* Finds all names in the initial input list that match phonetically with
* the supplied name
*
* @param phoneticName
* The name for which you want to find matches
* @return An ArrayList of all phonetically matching names
*/
public ArrayList<String> findMatchingNames(String phoneticName) {
ArrayList<String> matchedNames = new ArrayList<>();
for (String s : Pairs.keySet()) {
if (phoneticName.equals(Pairs.get(s))) {
matchedNames.add(s);
}
}
return matchedNames;
}
}