Skip to content

Instantly share code, notes, and snippets.

@jimbray
Created November 5, 2014 01:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jimbray/50a1b10fb9b0bf7db802 to your computer and use it in GitHub Desktop.
Save jimbray/50a1b10fb9b0bf7db802 to your computer and use it in GitHub Desktop.
HashMap根据value寻找key
/**
* 根据value寻找key
* @param map
* @param value
* @return
*/
public static String getMapKeyByValue(HashMap<String, String> map, Object value) {
Set<String> kset = map.keySet();
for(String ks : kset){
if(value.equals(map.get(ks))) {
return ks;
}
}
return null;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment