Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import java.util.*;

public class Main {
    public static boolean mapEquals(Map map1, Map map2) {
        if (map1 == null && map2 == null)
            return true;
        if (map1 == null || map2 == null)
            return false;
        if (map1.size() != map2.size())
            return false;
        for (Iterator i$ = map1.entrySet().iterator(); i$.hasNext();) {
            java.util.Map.Entry entry = (java.util.Map.Entry) i$.next();
            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;
        else
            return obj1.equals(obj2);
    }
}