how to compare two hash maps?

后端 未结 7 1019
独厮守ぢ
独厮守ぢ 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条回答
  • 2021-02-08 02:53
    Map map = new HashMap();
    map.put("AA","aaa");
    map.put("BB","bbb");
    map.put("CC","ccc");
    map.put("DD","ffffd");
    
    Map map2 = new HashMap();
    map2.put("BB","bbb");
    map2.put("AA","aaa");
    map2.put("DD","ffffd");
    map2.put("CC","ccc");
    
    if(map.equals(map2))
    {
        System.out.println("Eql");
    }
    else
    {
        System.out.println("Not");
    }
    
    0 讨论(0)
提交回复
热议问题