List list = new ArrayList();
list.add(new HashMap().put("1", "2")); //1
Map map = new HashMap();
map.put("1", "2");
list.add(map); //2
for (Iterator iterator = list.iterator(); iterator.hasNext();) {
Map map1 = (Map) iterator.next();
System.out.println(map1);
} 结果如下:
null
{1=2} 为何不同呢?
list.add(new HashMap().put("1", "2"));
list较hashMap快;
所以在没填充完HashMap list已经执行完毕