集合类基础知识

Posted t96fxi

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了集合类基础知识相关的知识,希望对你有一定的参考价值。

1.LinkedHashMap和HashMap和TreeMap和HashTable和concurrentHashTable的区别

HashMap是由数组和链表组成,先通过key的hash值来确定在数组中的位置,该位置可以放链表放相同hash值的entry

LinkedHashMap是有序的,继承了HashMap,entry放在双向链表Node中来确保有序存放。

TreeMap是排序的,自动升序排列。比较慢

Hashtable是线程安全的,性能差,整个方法synchronize。

ConcurrentHashMap是Java5后替代HashTable的,方法内部分synchronized性能比Hashtable好。

2.ArrayList和LinkedList和Vector的区别

ArrayList是数组结构,LinkedList是链表, Vector是线程安全的

3.HashSet和LinkedHashSet和TreeSet的区别

HashSet底层是HashMap

LinkedHashSet 底层是LinkedHashMap

TreeSet 底层是TreeMap是有序的,自动升序排列

以上是关于集合类基础知识的主要内容,如果未能解决你的问题,请参考以下文章