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 <K, V> Map<K, V> immutableMap(Map<K, V> map) {
        return Collections.unmodifiableMap(map);
    }

    public static <K, V> Map<K, V> immutableMap(Collection<Map.Entry<K, V>> entrySet) {
        Map<K, V> resultMap = new HashMap<K, V>();
        for (Map.Entry<K, V> entry : entrySet) {
            if (entry != null)
                resultMap.put(entry.getKey(), entry.getValue());
        }
        return Collections.unmodifiableMap(resultMap);
    }
}