Here you can find the source of MapEquals(Map
public static <TKey, TValue> boolean MapEquals(Map<TKey, TValue> mapA, Map<TKey, TValue> mapB)
//package com.java2s; import java.util.*; public class Main { public static <TKey, TValue> boolean MapEquals(Map<TKey, TValue> mapA, Map<TKey, TValue> mapB) { if (mapA == null) { return mapB == null; }//from w w w. j a v a2 s. co m if (mapB == null) { return false; } if (mapA.size() != mapB.size()) { return false; } for (Map.Entry<TKey, TValue> kvp : mapA.entrySet()) { TValue valueB = null; boolean hasKey; valueB = mapB.get(kvp.getKey()); hasKey = (valueB == null) ? mapB.containsKey(kvp.getKey()) : true; if (hasKey) { TValue valueA = kvp.getValue(); if (!(((valueA) == null) ? ((valueB) == null) : (valueA).equals(valueB))) { return false; } } else { return false; } } return true; } }