Collection & Map的总结
引出:为了解决数组定长的问题。实际是动态的对象数组。
集合类 |
null值判断 |
构成 |
说明 |
|
List |
ArrayList |
|
数组 |
不安全 |
LinkedList |
双向链表 |
不安全 |
||
Vector |
数组 |
安全 |
||
Set |
HashSet(无序存储) |
允许为null |
哈希表+红黑树 |
|
TreeSet(有序存储) |
不允许为null |
红黑树 |
|
Set就是value值相同的Map集合,现有Map才有Set
集合类 | Key | Value | 构成 | 说明 |
---|---|---|---|---|
HashTable | 不允许为null | 不允许为null | 哈希表 | 线程安全 |
ConcurrentHashMap | 不允许为null | 不允许为null | 线程安全 | |
TreeMap | 不允许为null | 允许为null | 红黑树 | 线程不安全 |
HashMap | 允许为null | 允许为null | 哈希表+红黑树 | 线程不安全 |