LinkedHashMap的底层实现
/*
四、LinkedHashMap的底层实现原理(了解)
源码中:
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);
}
}
*/
@Test
public void test2(){
Map map = new HashMap();
map=new LinkedHashMap();//按添加顺序输出
map.put(123, "AA");
map.put(345, "BB");
map.put(12, "CC");
System.out.println(map);
}