Updating an object inside an hashmap
in
Programming Questions
•
1 year ago
description:
i have a hashmap with objects (class Child), i wonder if when i get the object from the hashmap is by reference and if i update it, will change inside the hashmap. if not, how can i update it.
code:
HashMap Parent = new HashMap(); // the hashmap
Child child = (Child) Parent.get(id); // geting the object
child.update(school,grade); // running objects update function
result:
gives no error, but doesn't update the hasmap.
help needed, thanks
edit: if i put it back in, will be duplicated?
i have a hashmap with objects (class Child), i wonder if when i get the object from the hashmap is by reference and if i update it, will change inside the hashmap. if not, how can i update it.
code:
HashMap Parent = new HashMap(); // the hashmap
Child child = (Child) Parent.get(id); // geting the object
child.update(school,grade); // running objects update function
result:
gives no error, but doesn't update the hasmap.
help needed, thanks
edit: if i put it back in, will be duplicated?
1