How can I best compare two HashMap
s, if I want to find out if none of them contains different keys than the other, and if the values of that keys match each oth
public boolean compareMap(Map map1, Map map2) {
if (map1 == null || map2 == null)
return false;
for (String ch1 : map1.keySet()) {
if (!map1.get(ch1).equalsIgnoreCase(map2.get(ch1)))
return false;
}
for (String ch2 : map2.keySet()) {
if (!map2.get(ch2).equalsIgnoreCase(map1.get(ch2)))
return false;
}
return true;
}