I have a HashMap<Ist, Ist> registro = new HashMap<Ist, Ist>()
I need to find the key of certain values, for which im using this method I found
public static <T, E> T getKeyByValue(Map<T, E> map, E value) {
for (Map.Entry<T, E> entry : map.entrySet()) {
if (Objects.equals(value, entry.getValue())) {
return entry.getKey();
}
}
return null;
}
I do registro.put(origenCopia, istOrigen)
However getKeyByValue(this.registro, istDestino)
returns null, I'm guessing it's because istDestino and istOrigen aren't the exact same objects, but their contents are.