[Java] Get key from value

Ref: Java Hashmap: How to get key from value?

private Object getKeyFromValue(Map map, Object value) {
    for (Object object : map.keySet()) {
        if (map.get(object).equals(value)) {
            return object;
        }
    }
    return null;
}
This entry was posted in Java. Bookmark the permalink.