??????????????????Map????????????????????????±??????????????????????Map?????????????????????????????????????????????key??????????????value????????????????????
????HashMap???hashcode??????????п????????? TreeMap?????е??????????????????????????????????????????????????TreeMap??HashMap????????????????????????
????HashMap ??????? TreeMap ???????
?????????
??????Java???????????????????????棺
????1?????thread??????java?????????read??modify????????????????????????????synchronized????ArrayList??Vector??HashMap??Hashtable
??????????????????????synchronized???????????????interator???List??????????????remove???element????????????
????2??????????????????Σ????????????????乲??????????????java.lang.ThreadLocal???????Java?????????????static??transient??????
????1.AbstractMap???????SortedMap???
????AbstractMap??????(HashMap???AbstractMap)??????equals()??hashCode()?????????????????????????????????????????С?????????????????????????????????ж????????????????????????????????????????????????????????????????Map.Entry??????????????????????????????Σ???????????????????????
????SortedMap??????TreeMap?????SortedMap??????????????????????SortedMap???????????(???)??????????????????????????????????????????????????????SortedMap?????SortedSet?????????SortedMap???????????????Comparable?????????????????????????????Comparator????????TreeMap???????????????
????2.???????Map???
????HashMap?????????????????HashMap???????????????????hashCode()??equals()[??????дhashCode()??equals()]????????HashMap?????????????????????????????????
????(1)HashMap(): ???????????????
????(2)HashMap(Map m): ???????????????????????m?????????
????(3)HashMap(int initialCapacity): ??????????????????????????
????(4)HashMap(int initialCapacity?? float loadFactor): ??????????????????????????????????
????TreeMap??????????????TreeMap??е?????????????????????????
????(1)TreeMap():???????????????
????(2)TreeMap(Map m): ????????????????????????m?????????
????(3)TreeMap(Comparator c): ???????????????????????????????????????????
????(4)TreeMap(SortedMap s): ??????????????????????s?????????????????????????s?????????????
????3.???????Map????
????HashMap??????????Map?в?????????λ????
????Treemap?????????????????????????????(key)??
????4.???
????HashMap?????TreeMap?????(????????????????)??????????HashMap????????????Map??????TreeMap??

 

import java.util.HashMap;
import java.util.Hashtable;
import java.util.Iterator;
import java.util.Map;
import java.util.TreeMap;
public class HashMaps {
public static void main(String[] args) {
Map<String?? String> map = new HashMap<String?? String>();
map.put("a"?? "aaa");
map.put("b"?? "bbb");
map.put("c"?? "ccc");
map.put("d"?? "ddd");
Iterator<String> iterator = map.keySet().iterator();
while (iterator.hasNext()) {
Object key = iterator.next();
System.out.println("map.get(key) is :" + map.get(key));
}
// ????HashTable??????????
Hashtable<String?? String> tab = new Hashtable<String?? String>();
tab.put("a"?? "aaa");
tab.put("b"?? "bbb");
tab.put("c"?? "ccc");
tab.put("d"?? "ddd");
Iterator<String> iterator_1 = tab.keySet().iterator();
while (iterator_1.hasNext()) {
Object key = iterator_1.next();
System.out.println("tab.get(key) is :" + tab.get(key));
}
TreeMap<String?? String> tmp = new TreeMap<String?? String>();
tmp.put("a"?? "aaa");
tmp.put("b"?? "bbb");
tmp.put("c"?? "ccc");
tmp.put("d"?? "cdc");
Iterator<String> iterator_2 = tmp.keySet().iterator();
while (iterator_2.hasNext()) {
Object key = iterator_2.next();
System.out.println("tmp.get(key) is :" + tmp.get(key));
}
}
}