I have this object:
Map<Long, Set<String>> resourcesByID = new HashMap<Long, Set<String>>();
and another:
Set<String> resources;
When I want to put more Set into the HashMap it will override the elements of the Set, that I put into previously. Why? And how can I resolve this problem?
If
keymatches, it overrides the previous values, otherwise it won’t override.(or)
As Thomas commented, if your set is mutate and you are updating the same set, yes, then it may override.