当前位置: 技术问答>java相关
关于HashSet的问题?
来源: 互联网 发布时间:2015-05-08
本文导语: 86. which statement is true for the class java.util.HashSet? A.The elements in the collection are ordered B.The collection is guaranteeded to be immutable C.The elements in the collection are guaranteeded to be unique D.The...
86. which statement is true for the class java.util.HashSet?
A.The elements in the collection are ordered
B.The collection is guaranteeded to be immutable
C.The elements in the collection are guaranteeded to be unique
D.The elements in the collection are access using a unique key
E.The elements in the collection are guaranteed to be synchronized
答案是C,可是D为什么不对呢?
A.The elements in the collection are ordered
B.The collection is guaranteeded to be immutable
C.The elements in the collection are guaranteeded to be unique
D.The elements in the collection are access using a unique key
E.The elements in the collection are guaranteed to be synchronized
答案是C,可是D为什么不对呢?
|
HashSet实现了Set,而不是实现Map,Set的关键定义是not allow duplicate,Map的关键定义才是key-value map。我的认为HashSet并没有key-value的映射,而只是用hash来散列set中的value。
|
HashSet虽然名字叫Hash,可是实际上是set,只是实现了所包含的元素的唯一性,而key-value说的应该是Map,也就是Hash之类的东东,所以当然是C了。
|
HashSet is a set, with every element unique, but implemented in the hash way. For example, (2, 3) and (2, 4) are different, but they share the same key 2 in hash bucket. So you cannot locate an element just by its unique key.
您可能感兴趣的文章:
本站(WWW.)旨在分享和传播互联网科技相关的资讯和技术,将尽最大努力为读者提供更好的信息聚合和浏览方式。
本站(WWW.)站内文章除注明原创外,均为转载、整理或搜集自网络。欢迎任何形式的转载,转载请注明出处。
本站(WWW.)站内文章除注明原创外,均为转载、整理或搜集自网络。欢迎任何形式的转载,转载请注明出处。