import java.util.*;
public class Test{
public static void main(String[] args) {
// TODO Auto-generated method stub
IdentityHashMap<Integer, String> map =new IdentityHashMap<Integer, String>();
String s1 =new String("test");
map.put(new Integer(4), s1);
map.put(new Integer(4), s1);
System.out.println(map.size());
map.put(4, s1);
map.put(4, s1);
System.out.println(map.size());
for(String s : map.values()){
System.out.println(s);
}
}
}
基本数据类型放入集合中java自动集装箱不是应该会创建相应的外部包装器吗?为什么map.put(new Integer(4), s1); 与 map.put(4, s1);的效果不一样