【发布时间】:2014-09-16 06:49:51
【问题描述】:
当我们将空 Map 放入 Map 后获取大小时,它会给出空指针异常。 当我们知道 HashMap 允许放置空值和键时。 为什么当我们放空 Map 时会发生这种情况。
public static void main(String[] args){
Map<String, Integer> n=new HashMap<String, Integer>();
n.put("1", 1);
System.out.println(n.size());
Map<String, Integer> nn=null;
n.putAll(nn);
System.out.println(n.size());
}
【问题讨论】:
标签: java collections