IdentityHashMap中 直接放入基本数据类型与 new Integer()的区别

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);的效果不一样

map.put(4, s1);//这两装箱后用的是Integercache中的,是同一个对象,integer会初始化-128-127到integercache中,这些整型装箱时都是一个对象
map.put(4, s1);

map.put(new Integer(4), s1);//new出来的,是两个不同的对象
map.put(new Integer(4), s1);    

    你可以改成map.put(129, s1);