int i = 123;
Integer a = new Integer(i);
int b = i;
Integer c = new Integer(i);
System.out.println(a == b);
System.out.println(b == c);
System.out.println(a == c);
好吧,看谁能给出正确答案!
...全文
92294打赏收藏
a=b, b=c, a=c??
给大家出个题 a=b, b=c, a=c?? 用代码来看吧: int i = 123; Integer a = new Integer(i); int b = i; Integer c = new Integer(i); System.out.println(a == b); System.out.println(b == c); System.out.println(a == c); 好吧,看谁能给出正确答案!
int i = 123;
Integer a = new Integer(i);
int b = i;
Integer c = new Integer(i);
System.out.println(a ==……
[/Quote]
TTT
前边2个不用说了,最后一个只要在 -128 ~ 127 的范围内也是True
public static Integer valueOf(int i) {
final int offset = 128;
if (i >= -128 && i <= 127) { // must cache
return IntegerCache.cache[i + offset];
}
return new Integer(i);
}