you remove
returns false
because you are trying to remove Person
object, but you don't have it in the map
.
Notice you are adding Collection<Person>
to map
, but trying to remove Person
, obviously those 2 objects are not equal
, therefore you get false
value.
after : map.put(1, set);
in memory you have something like :
1=>[[p]];
but ,i guess, you expected 1=>[p]
.
just replace map.put(1,set);
with map.put(1,p);
Also take a look at Guillaume Poussel
answer for proper MultiMap implementation advice.