LinkedHashMap

LinkedHashMap是HashMap的一个子类;

LinkedHashMap的使用

 

LinkedHashMap保存了记录的插入顺序,在用Iterator遍历LinkedHashMap时,先得到的记录肯定是先插入的;

在遍历的时候会比HashMap慢,不过有种情况例外,当HashMap容量很大,实际数据较少时,遍历起来可能会比LinkedHashMap慢,因为LinkedHashMap的遍历速度只和实际数据有关,和容量无关,而HashMap的遍历速度和他的容量有关。

LinkedHashMap的使用

相关文章:

  • 2021-06-14
  • 2022-03-09
  • 2022-01-06
  • 2021-08-13
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-01-29
  • 2022-02-20
相关资源
相似解决方案