public class TestInteger {
public static void main(String[] args) {
Integer s1 = 127, s2 = 127, t1 = 128, t2 = 128;
System.out.println(s1 == s2);
System.out.println(s1.equals(s2));
System.out.println(t1 == t2);
System.out.println(t1.equals(t2));
System.out.println(t1.intValue() == t2.intValue());
}
public static void main(String[] args) {
Integer s1 = 127, s2 = 127, t1 = 128, t2 = 128;
System.out.println(s1 == s2);
System.out.println(s1.equals(s2));
System.out.println(t1 == t2);
System.out.println(t1.equals(t2));
System.out.println(t1.intValue() == t2.intValue());
}
}
比较答案:
true
true
false
true
true