集合类基础知识

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是有序的,自动升序排列

猜你喜欢

转载自www.cnblogs.com/t96fxi/p/12397749.html