关于Hashset的提问

来源:百度知道 编辑:UC知道 时间:2024/06/21 07:48:32
Which statement is true for the class java.util.HashSet?

A. The elements in the collection are ordered.

B. The collection is guaranteed to be immutable.

C. The elements in the collection are guaranteed to be unique.

D. The elements in the collection are accessed using a unique key.

E. The elements in the collections are guaranteed to be synchronized.

Answer: C

请问a怎么不对?不是根据哈希算法储存么?...

Hash算法不是根据顺序排列的,而是通过hash函数的key-value对来实现的,所以插入一个元素,需要提供key,value,查找只需要一个key,a选项是说是ordered是错误的。

并没有顺序关系存在,它是散列的而非连续的。