Java tutorial
//package com.java2s; import java.util.HashMap; import java.util.Map; public class Main { public static <K, V> Map<V, K> reverseKeyValue(Map<K, V> map) { if (map == null) { return null; } Map<V, K> newMap = new HashMap<V, K>(); for (Map.Entry<K, V> entry : map.entrySet()) { newMap.put(entry.getValue(), entry.getKey()); } return newMap; } }