Map的value取得key

转载 http://hi.baidu.com/sonos/item/2510a3166cb377c838cb30a4

protected List getKeyByValue(Map map, Object value) {
List keys = new ArrayList();
Iterator it = map.entrySet().iterator();
while (it.hasNext()) {
Map.Entry entry = (Entry) it.next();
Object obj = entry.getValue();
if (obj != null && obj.equals(value)) {
keys.add(entry.getKey());
}

}
return keys;
} 

你可能感兴趣的:(value)