Here you can find the source of reverse(Map
public static <K, V> Map<V, K> reverse(Map<K, V> kvMap)
//package com.java2s; //License from project: Open Source License import java.util.*; public class Main { public static <K, V> Map<V, K> reverse(Map<K, V> kvMap) { Map<V, K> vkMap = new HashMap<V, K>(kvMap.size()); for (Map.Entry<K, V> e : kvMap.entrySet()) { vkMap.put(e.getValue(), e.getKey()); }/* www.jav a 2 s . c o m*/ return vkMap; } }