DarkPhoenixX
Mitglied
Wie kann man bei einer HashMap durch den Wert einen bestimmten Schlüssel abfragen?
Danke im Vorraus
Danke im Vorraus
Follow along with the video below to see how to install our site as a web app on your home screen.
Anmerkung: This feature currently requires accessing the site using the built-in Safari browser.
/**
*
*/
package de.tutorials;
import com.google.common.collect.BiMap;
import com.google.common.collect.Maps;
/**
* @author Thomas.Darimont
*
*/
public class ReverseMapLookupExample {
/**
* @param args
*/
public static void main(String[] args) {
BiMap<String, Integer> map = Maps.newHashBiMap();
map.put("eins",1);
map.put("zwei",2);
map.put("drei",3);
System.out.println(map.get("eins"));
System.out.println(map.get("drei"));
BiMap<Integer,String> inverseMap = map.inverse();
System.out.println(inverseMap.get(1));
System.out.println(inverseMap.get(3));
}
}
1
3
eins
drei