写出下面方法的输出结果:
public static void main(String args[]) {
Integer a = 100;
Integer b = 100;
if (a == b) {
System.out.println("true");
} else {
System.out.println("false");
}
Integer c = 1000;
Integer d = 1000;
if (c == d) {
System.out.println("true");
} else {
System.out.println("false");
}
}

解决方案 »

  1.   

    我感觉应该是两个false 不知道对不
      

  2.   

    false,false. 是不是在考装箱机制?
      

  3.   

    很无聊的题目,考背诵?
    http://java.sun.com/docs/books/jls/third_edition/html/conversions.html#5.1.7
      

  4.   

    Integer类的内部, 有一个常量静态数组, 在Integer类被加载的时候, 预先创建了-128 ~ 127的Integer对象, 所以当声明的Integer类型变量的值在-128 ~ 127的范围内时, 不会新创建对象, 直接引用数组中创建好的.   所以第一个结果会输出true