Here you can find the source of reverseKeyAndValue(Map map)
public static Map reverseKeyAndValue(Map map)
//package com.java2s; //License from project: Apache License import java.util.HashMap; import java.util.Map; import java.util.Set; import java.util.Map.Entry; public class Main { public static Map reverseKeyAndValue(Map map) { Map reverseMap = new HashMap(); for (Entry entry : (Set<Entry>) map.entrySet()) { reverseMap.put(entry.getValue(), entry.getKey()); }//from w w w . j av a 2 s. c om return reverseMap; } }