LinkedHashMap+ConcurrentHashMap+hashMap的区别

①LinkedHashMap:
1.LinkedHashMap是有序的
2.每次访问一个元素(get或put),被访问的元素都被提到最后面去了
3.非线程安全

关  注  点 结      论
LinkedHashMap是否允许空 Key和Value都允许空
LinkedHashMap是否允许重复数据 Key重复会覆盖、Value允许重复
LinkedHashMap是否有序 有序
LinkedHashMap是否线程安全 非线程安全

 

 

 

 

 

 

② ConcurrentHashMap:

线程安全,使用了分段锁,在线程需要安全的时候,使用ConcurrentHashMap替代LinkedHashMap

③hashMap

1.遍历顺序却是不确定的。 

2.HashMap最多只允许一条记录的键为null,允许多条记录的值为null。

3.HashMap非线程安全

原文地址:https://www.cnblogs.com/xxj-bigshow/p/7503889.html