LinkedHashMap的使用

LinkedHashMap

LinkedHashMap是HashMap的一个子类;

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

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

发布了103 篇原创文章 · 获赞 1 · 访问量 2347

猜你喜欢

转载自blog.csdn.net/W_317/article/details/103984568