public static <A, B> HashMap<B, A> reverseHashMap(HashMap<A, B> map)
//package com.java2s; //License from project: Open Source License import java.util.HashMap; public class Main { public static <A, B> HashMap<B, A> reverseHashMap(HashMap<A, B> map) { HashMap<B, A> reverseMap = new HashMap<B, A>(); for (A a : map.keySet()) { B b = map.get(a);//from w w w.j av a 2 s . c o m reverseMap.put(b, a); } return reverseMap; } }