下面程序输出的是什么?解释下原因
package com;public class Test {
public static void main(String[] args) {
Integer v1 = 100;
Integer v2 = 100;
System.out.println(v1 == v2);
Integer w1 = 200;
Integer w2 = 200;
System.out.println(w1 == w2);
}
}
package com;public class Test {
public static void main(String[] args) {
Integer v1 = 100;
Integer v2 = 100;
System.out.println(v1 == v2);
Integer w1 = 200;
Integer w2 = 200;
System.out.println(w1 == w2);
}
}
在-128到127之间,封装类中的Byte、Short、Integer、Long进行了优化
在-128-127之间 就不用重新创建 。jdk里面 已经自动创建了
在-128-127之间 就不用重新创建 。看源码!