java - Unsupported add/addAll operations for Map<K,V>.keySet() -
regarding map<k,v>
interface:
why keyset()
return set
supports remove
operation doesn't support add()
, addall()
operations?
the set
returned keyset
backed map
, changes map reflected in set, , vice-versa. means calling remove
on set
removes matching entry
map
.
it make no sense call add
or addall
on set
, since can't add key[s] without corresponding value[s] map
.
Comments
Post a Comment