public class Demo4_Integer面试题 {
public static void main(String[] args) {
Integer s1 = new Integer(98);
Integer s2 = new Integer(23);
System.out.println(s1 == s2);
System.out.println(s1.equals(s2));
System.out.println("===============");
Integer s3 = 200;
Integer s4 = 200;//超过byte的范围了则是重新创建对象
System.out.println(s3 == s4);
System.out.println(s3.equals(s4));
Integer s5 = 89;
Integer s6 = 89;//在Integer的范围在-128~127之间的数,内存中不重新创建新的对象,而是从常量池中那,
//超过则是重新创建.
System.out.println(s5 == s6);
System.out.println(s5.equals(s6));
}
}