Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import java.util.HashMap;

import java.util.Map;
import java.util.Map.Entry;

public class Main {

    public static <K, V> Map<V, K> reverseMap(Map<K, V> map) {
        if (map != null) {
            Map<V, K> retMap = new HashMap<V, K>();
            for (Entry<K, V> entry : map.entrySet()) {
                retMap.put(entry.getValue(), entry.getKey());
            }
            return retMap;
        }
        return null;
    }
}