0

I have a question regarding setters for a returned object. I have a class with a private HashMap and a get method. The HashMap contains Minions (a class also having private values with getters and setters) as values. When I now do

Minion testMinion = MyClass.getMinion(somestuffhere);
testMinion.setLevel(9);

Does only the level of the variable testMinion change so I'd have to update the HashMap with the new Minion or does this modify the original Minion in the HashMap since testMinion is just a reference to it?

0 Answers0