I've created a loop which goes through my HashMap
. Then I check whether the name of the current key (A) is equal to the key that might be added (B). The hash codes of key A and key B aren't necessarily equal when their names are. Therefore I check whether they are equal by transforming them into a string (with override of .equals()). The code is working but there most be a cleaner and easier way to do this.
This is my current code:
for (HashMap.Entry<Identifier, SetInterface<BigInteger>> entry : idAndSet.entrySet()) {
if (entry.getKey().isEqual(identifier)) {
factor = entry.getValue();
return factor;
}
}