Java Map????????????
???????????? ???????[ 2013/4/11 10:09:30 ] ????????
????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);
}
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11