Here you can find the source of mapEquals(Map, ?> map1, Map, ?> map2)
public static boolean mapEquals(Map<?, ?> map1, Map<?, ?> map2)
//package com.java2s; //License from project: Apache License import java.util.*; public class Main { public static boolean mapEquals(Map<?, ?> map1, Map<?, ?> map2) { if (map1 == null && map2 == null) { return true; }//from w ww . j a v a 2 s . c o m if (map1 == null || map2 == null) { return false; } if (map1.size() != map2.size()) { return false; } for (Map.Entry<?, ?> entry : map1.entrySet()) { Object key = entry.getKey(); Object value1 = entry.getValue(); Object value2 = map2.get(key); if (!objectEquals(value1, value2)) { return false; } } return true; } private static boolean objectEquals(Object obj1, Object obj2) { if (obj1 == null && obj2 == null) { return true; } if (obj1 == null || obj2 == null) { return false; } return obj1.equals(obj2); } }