Here you can find the source of reverseMapLookup(Map
public final static <K, V> K reverseMapLookup(Map<K, V> map, V value)
//package com.java2s; /* Copyright (C) 2016 Zach Ohara * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version./* w ww .ja va2s . co m*/ * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ import java.util.Map; import java.util.Map.Entry; public class Main { public final static <K, V> K reverseMapLookup(Map<K, V> map, V value) { for (Entry<K, V> entry : map.entrySet()) { if (entry.getValue() == value) { return entry.getKey(); } } return null; } }