public class NewClass1 {
public static void main(String[] args) {
Map<Integer, String> testMaps = new HashMap<Integer, String>();
testMaps.put(10, "a");
testMaps.put(20, "b");
testMaps.put(30, "c");
testMaps.put(40, "d");
for (Entry<Integer, String> entry : testMaps.entrySet()) {
if (entry.getValue().equals("c")) {
System.out.println(entry.getKey());
}
}
}
}
Above method may not be good if your hashmap is really big. If your hashmap contain unique key to unique value mapping, you can maintain one more hashmap that contain mapping from Value to Key.
That is you have to maintain two hashmaps
1. Key to value
2. Value to key