1.容器
主要包括:
- Collection:存储着对象的集合
- Map:存储着键值对(两个对象) 的映射表。
1.1 Collection
- Set
- List
- Queue
1.1.1 Set
- TreeSet:
- HashSet
- LinkedHashSet
对比:
基于 | 支持 | 时间复杂度 | |
---|---|---|---|
TreeSet | 红黑树 | 有序性操作 | O(logN) |
HashSet | 哈希表 | 快速查,不支持有序性操作 | O(N) |
LinkedHashSet | 双向链表 | 使用双向链表维护 | O(N) |
1.1.2 List
- ArrayList
- Vector
- LinkedList
对比: