How does Java order items in a HashMap or a HashTable?

前端 未结 7 1482
星月不相逢
星月不相逢 2020-11-27 14:31

I was wondering how Java orders items in the Map (HashMap or Hashtable) when they are added. Are the keys ordered by the hashcode, mem

7条回答
  •  南笙
    南笙 (楼主)
    2020-11-27 14:57

    There is no defined ordering in a hash table. Keys are placed into a slot, based on the hash code, but even that isn't a trivial order-by-hash-code.

提交回复
热议问题