Here you can find the source of inverse(Map
public static <K, V> Map<V, K> inverse(Map<K, V> m, Map<V, K> newMap)
//package com.java2s; // The MIT License (MIT) import java.util.Map; import java.util.Map.Entry; public class Main { public static <K, V> Map<V, K> inverse(Map<K, V> m, Map<V, K> newMap) { for (Entry<K, V> entry : m.entrySet()) { newMap.put(entry.getValue(), entry.getKey()); }/* www . j av a 2 s . c om*/ return newMap; } }