public class example {
public static void main(String[] args) {
Integer a=127,b=127;
if(a==b)
System.out.println("Equal");
else
System.out.println("Not Equal");
Integer c=128,d=128;
if(c==d)
System.out.println("Equal");
else
System.out.println("Not Equal");
}
}
輸出:
Equal
Not Equal
的源代碼,他們又來了!它已被問很多次了... – Burkhard
用以下選項之一試用它:'-Djava.lang.Integer.IntegerCache.high = 128'或'-XX:AutoBoxCacheMax = 128'或 '-XX:+ AggressiveOpts ' –