请教大神们一个java包装类的问题

请教大神们一个java包装类的问题,

String str = "abc";
String str2 = "abc";
System.out.println(str == str2);

Integer i = Integer.valueOf(1);
Integer i2 = Integer.valueOf(1);
System.out.println(i ==i2);

我知道str和str2是存放在字符串常量池中的,所以他们是相等的,但是i和i2相等能说明这两个是同一个对象吗? 我认为i和i2相等是因为 比较它们的时候自动拆箱,按照基本数据类型来比较了, 另外关于基本类型比如int,也是类似于String常量池那样存储的吗? 就是说我有两个int值如果相等的话,它们在内存中是否就是相同的呢?

这个问题是在看 think in java 第17章 深入理解容器 时想到的,书中在将填充容器时写了一个填充Integer的自定义的List,然后说这是享元,我有点想不明白,求大神们指点呀!下面是书中的代码:

 public class CountingIntegerList
extends AbstractList<Integer> {

private int size;
public CountingIntegerList(int size) {
this.size = size < 0 ? 0 : size;
}
public Integer get(int index) {
//我这里不太明白,难道每次按照相同index取出的Integer都是同一个对象???
return Integer.valueOf(index);
}
public int size() { return size; }
public static void main(String[] args) {
System.out.println(new CountingIntegerList(30));
}
}

的确 为一个对象,范围是-128 至 127

 static final int low = -128;
        static final int high;
        static final Integer cache[];

        static {
            // high value may be configured by property
            int h = 127;
            String integerCacheHighPropValue =
                sun.misc.VM.getSavedProperty("java.lang.Integer.IntegerCache.high");
            if (integerCacheHighPropValue != null) {
                int i = parseInt(integerCacheHighPropValue);
                i = Math.max(i, 127);
                // Maximum array size is Integer.MAX_VALUE
                h = Math.min(i, Integer.MAX_VALUE - (-low) -1);
            }
            high = h;

            cache = new Integer[(high - low) + 1];
            int j = low;
            for(int k = 0; k < cache.length; k++)
                cache[k] = new Integer(j++);
        }
 Integer.valueOf如果值范围在-128-127范围内,会从Integercache中获取,这里初始化了-128-127范围内的整形。所以会是同一个对象。
 如果是new Integer(1)就不一样了,这个是在堆中new对象,就不是同一个对象了。
 对于int,比较是字面数值,不是对象。int值存储在栈中。如果int值相同,只是同相同的位置load过来的,但没有地址指向的概念。

赞成@danielinbiti的回答