public static void main(String[] args) {
Integer i = new Integer(10);
Integer j = new Integer(10);
if (i == j){
System.out.println("相等");
}else {
System.out.println("不相等");
}
Integer a = 10;
Integer b = 10;
if (a == b){
System.out.println("相等");
}else {
System.out.println("不相等");
}
Integer m = 128;
Integer n = 128;
if (m==n){
System.out.println("相等");
}else {
System.out.println("不相等");
}
}
當new一個對象時就是創(chuàng)建一個空間,兩個對象地址不相同她紫。當在-127和127之間時稿蹲,默認使用int方式復制,超過整個區(qū)間則會創(chuàng)建對象