????1??????

????????Java??Map????????????????????????entrySet????????keySet??Ч????????????entrySet??????????????key??value????????keySet????????key????????????key??????Map?ж?????????value???????????????Ч??????????????????

???????????????????????????????key+value??????key??????value?????????μ????????????????Щ???????

????2????????

????????????????????????????????keySet?????????????????????????????entrySet???????keySet?????????????????????????????????????????и????????????

????2.1 ????????

????2.1.1 HashMap????????

????HashMap-1????С?100??key??value???String??key????1??2??3……1000000??

Map<String?? String> map = new HashMap<String?? String>();
String key?? value;
for (i = 1; i <= num; i++) {
    key = "" + i;
    value = "value";
    map.put(key?? value);
}

????HashMap-2????С?100??key??value???String??key????50??100??150??200??……??50000000??

Map<String?? String> map = new HashMap<String?? String>();
String key?? value;
for (i = 1; i <= num; i++) {
    key = "" + (i * 50);
    value = "value";
    map.put(key?? value);
}

????2.1.2 TreeMap????????

????TreeMap-1????С?100??key??value???String??key????1??2??3……1000000??

Map<String?? String> map = new TreeMap<String?? String>();
String key?? value;
for (i = 1; i <= num; i++) {
    key = "" + i;
    value = "value";
    map.put(key?? value);
}

????TreeMap-2????С?100??key??value???String??key????50??100??150??200??……??50000000?????????

Map<String?? String> map = new TreeMap<String?? String>();
String key?? value;
for (i = 1; i <= num; i++) {
    key = "" + (i * 50);
    value = "value";
    map.put(key?? value);
}

????2.2 ???????

??????????keySet??entrySet??values?????д???????????????????key+value??????key??????value???????

????2.2.1 ????key+value

????keySet????key+value??д??1????

Iterator<String> iter = map.keySet().iterator();
while (iter.hasNext()) {
    key = iter.next();
    value = map.get(key);
}

????keySet????key+value??д??2????

for (String key : map.keySet()) {
    value = map.get(key);
}