/* package whatever; // don't place package name! */

import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;

/* Name of the class has to be "Main" only if the class is public. */
class Ideone
{
	public static <T, E> T getKeyByValue(Map<T, E> map, E value) {
	
	    for (Entry<T, E> entry : map.entrySet()) {
	
	        if (value.equals(entry.getValue())) {
	            return entry.getKey();
	        }
	    }
	
	    return null;
	}
	
	public static void main (String[] args) throws java.lang.Exception
	{
		Map<String,String> myMap = new HashMap<String,String>();
		myMap.put("1","valor1");
		myMap.put("2","valor2");
		myMap.put("3","valor3");
		
		System.out.println(getKeyByValue(myMap,"valor1"));
	}
}