Use Map.get() and Map.put() methods.
A note about this process : you may ask "why the hell do I need to reinsert the item"? Isn't it enough to just update it? Well, unfortunately not, because the map doesn't know about the change.
Let's say we've got a binary search tree (say, a TreeMap in Java) :
2
1 3
If you update the record with 1 to 4, the map won't notice the change and you'll end up with an invalid BST :
2
4 3
Now, an odd situation might happen that bst.contains(4)
returns false
while bst.keySet().contains(4)
returns true
.
For more details, you can see this SO question.
In this case, it shouldn't be needed though because the keys (String
s) are immutable.