How to compare two hashmaps in java?

前端 未结 4 1855
眼角桃花
眼角桃花 2020-12-06 15:50

I have two hash maps like the following:

1.=============Employee=================


Key : 1_10 : Value : 13/04/2012
Key : 1_11 : Value : 18/04/2012
Key : 1_         


        
4条回答
  •  长情又很酷
    2020-12-06 16:20

    below is the code which works perfectly, the reason why the comparison failed is the map value is different .

    Key : 27 : Value : 27/4/2012, Key : 1_18 : Value : 27/04/2012
    

    if we see the dates, the difference is clearly seen. 27/4/2012 is different from 27/04/2012 since i stored it as a string.

    Iterator> holyDayiterator = workingdayMap.entrySet().iterator();
    
                     while (holyDayiterator.hasNext()) {
                        Map.Entry holiDayEntry = holyDayiterator.next();
                        if(!employeeMap.containsValue((holiDayEntry.getValue()))){
                            System.out.println("works perfect");
                        }
    

    Thanks guys for your support and people who have gave down vote also.

    :) Tony

提交回复
热议问题