- Set & Map
A -- object/key exists in set/map
B -- object/key to be added to set/map
If and only if
(B == A || B.equals(A)) && B.hashCode == A.hashCode
then keyAdd will overwrite the existed one.
- List
Can add any object
Can add the same object more than one time
A -- object/key exists in set/map
B -- object/key to be added to set/map
If and only if
(B == A || B.equals(A)) && B.hashCode == A.hashCode
then keyAdd will overwrite the existed one.
- List
Can add any object
Can add the same object more than one time
博客介绍了Set、Map和List中对象添加的规则。在Set和Map里,当(B == A || B.equals(A)) && B.hashCode == A.hashCode时,新添加的键会覆盖已有的;而List可以添加任意对象,且同一对象能多次添加。
790

被折叠的 条评论
为什么被折叠?



