当前位置:  技术问答>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为什么不对呢?

|
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.)站内文章除注明原创外,均为转载、整理或搜集自网络。欢迎任何形式的转载,转载请注明出处。












  • 相关文章推荐
  • java命名空间java.util类hashset<e>的类成员方法: hashset定义及介绍
  • Java中HashMap和Hashtable及HashSet的区别
  • java命名空间java.util类hashset<e>的类成员方法: clone定义及介绍
  • 浅析Java中Map与HashMap,Hashtable,HashSet的区别
  • java命名空间java.util类hashset<e>的类成员方法: clear定义及介绍
  • java命名空间java.util类hashset<e>的类成员方法: size定义及介绍
  • java命名空间java.util类hashset<e>的类成员方法: isempty定义及介绍
  • java命名空间java.util类hashset<e>的类成员方法: contains定义及介绍
  • java命名空间java.util类hashset<e>的类成员方法: add定义及介绍
  • java命名空间java.util类hashset<e>的类成员方法: remove定义及介绍


  • 站内导航:


    特别声明:169IT网站部分信息来自互联网,如果侵犯您的权利,请及时告知,本站将立即删除!

    ©2012-2021,,E-mail:www_#163.com(请将#改为@)

    浙ICP备11055608号-3