how to compare two hash maps?

后端 未结 7 1066
独厮守ぢ
独厮守ぢ 2021-02-08 02:22

How to compare the values in both hash maps with the help of keys ? Since the keys are identical whereas values are\'nt. and return boolean result for each key comparision. like

7条回答
  •  旧时难觅i
    2021-02-08 02:32

    Pseudo Code:

    HashMap map1;
    HashMap map2;
    HashMap resultMap;
    for(KeyType key : map1.keySet() ) {
      if(map1.get(key).equals(map2.get(key)){
        resultMap.put(key,true);
      } else {
        resultMap.put(key,false);
      }   
    

    }

提交回复
热议问题