一 线程安全性
TreeMap,HashMap,LinkedHashMap:非线程安全
Hashtable,Properties:线程安全
二 实现方式
TreeMap:红黑树
HashMap: 数组 + 单链表/红黑树
transient Node<K,V>[] table;
static class Node<K,V> implements Map.Entry<K,V> {
final int hash;
final K key;
V value;
Node<K,V> next;
......
}
LinkedHashMap:HashMap + 双向链表
transient LinkedHashMap.Entry<K,V> head;
transient LinkedHashMap.Entry<K,V> tail;
static class Entry<K,V> extends HashMap.Node<K,V> {
Entry<K,V> before, after;
Entry(int hash, K key, V value, Node<K,V> next) {
super(hash, key, value, next);
}
}
Hashtab