问题描述:
在java语言中,map的clear方法会把整个map清空吗?
问题解答:
答案是肯定的
测试代码:
HashMap hashMap = new HashMap();
hashMap.put(“1”, “mqboss”);
hashMap.put(“2”, “Jboss”);
System.out.println(“hashMap: ” + hashMap);
hashMap.clear();
System.out.println(“hashMap: ” + hashMap);
测试输出:
hashMap: {2=Jboss, 1=mqboss}
hashMap: {}
=====================
from:http://blog.csdn.net/mqboss/article/details/1671884 Salute to the author