java集合比较:
List | 是否有序 | 是否重复元素 | 说明 | |
ArrayList | 是 | 是 | 数组结构,查询快 | |
LinkedList | 链表结构,增,删快 | |||
Set | HashSet | 否 | 否 | |
LinkedHashSet | 插入集合的元素顺序与输出顺序保持一致 | |||
TreeSet | 是(用二叉排序树) | 否 | 按照Comparator来进行排序 | |
Map | HashMap | 否 | key必须唯一,value可以重复 | 底层是哈希表,执行hashCode,和equals方法 |
LinkedHashMap | 否 | 插入集合的元素顺序与输出顺序一致 | ||
TreeMap | 是(用二叉排序树) | 按字符串排序进行输出 | ||
HashTable | 否 | 线程安全,效率比较低 | ||
CurrentHashMap | 否 | 多线程使用 |