Map
- Map给定长度时,put会更快,没长度的情况下,每次put都需要扩容
- 在对map做遍历时,如果在循环内需要用到value值,要用entrySet做遍历,而不是用keySet之后再从map取value
- 又测试了map.forEach,不容乐观啊
int i, count = 2000;
// Map定长时 put数据会更快
System.out.println("start: " + System.currentTimeMillis());
Map<String, Integer> map = new HashMap<>();
for (i=0; i<count; i++) {
map.put(String.valueOf(i), i)