byte,关于127+1等于多少
public class Main {
public static void main(String[] args) {
Integer i1 = 100;
Integer i2 = 100;
Integer i3 = 200;
Integer i4 = 200;
System.out.println(i1==i2);
System.out.println(i3==i4);
}
}
输出结果为:true,false
输出得结果i1和i2指向得是同一个对象,而i3和i4指向得是不同得项目,具体看源码:
public static Interger valueOf(int i){
if(i>=-128&&i<=IntergerCache.high){
return IntergerCache.cache[i+128];
}else{
return new Interger(i);
}
}