Java 基础之集合_java集合继承关系图-CSDN博客
集合可以有序或无序,重复或不能重复,空或不能空。
List<> 集合,是有序,允许重复元素,允许空元素
1、ArrayList<> 非线程安全
2、LInkedList<> 非线程安全
Doubly-linked list implementation of the List and Deque interfaces.
是实现List 和 Deque的双向列表
3、vector 是线程安全的,容量大小可以改变,跟数组一样索引访问
4、栈
Stack<E> extends Vector<E>
Queue
public interface Queue<E> extends Collection<E> {
public interface Deque<E> extends Queue<E>
A linear collection that supports element insertion and removal at both ends. The name deque is short for "double ended queue"
ArrayDeque 非线程安全
Null elements are prohibited. This class is likely to be faster than Stack when used as a stack, and faster than LinkedList when used as a queue
Set<>集合元素不能重复,最多允许一个空元素
HashSet<> 非线程安全
this class implements the Set interface, backed by a hash table (actually a HashMap instance).
TreeSet<> 非线程安全
A NavigableSet implementation based on a TreeMap. The elements are ordered using their natural ordering, or by a Comparator provided at set creation time, depending on which constructor is used.
This implementation provides guaranteed log(n) time cost for the basic operations (add, remove and contains).
Map<>集合
1、HashMap<> 不能保证顺序,key 不能重复,允许空key 和空val
2、TreeMap 可以保证顺序,非线程安全,是排序的map
基于红黑树,时间复杂度log(n)
A Red-Black tree based NavigableMap implementation. The map is sorted according to the natural ordering of its keys, or by a Comparator provided at map creation time, depending on which constructor is used.
This implementation provides guaranteed log(n) time cost for the containsKey, get, put and remove operations. Algorithms are adaptations of those in Cormen, Leiserson, and Rivest's Introduction to Algorithms.
3、Hashtable<> 是线程安全的,不允许空key 和 空val