public class TestClass {
public static void main(String[] args) {
Integer a= new Integer(5);
Integer b= new Integer(5);
Integer c=127;
Integer d = 127;
Integer e = 128;
Integer f = 128;
int g = 128;
System.out.println(a==b);
System.out.println(a.equals(b));
System.out.println(c == d);
System.out.println(e == f);
System.out.println(f == g);
}
public static void main(String[] args) {
Integer a= new Integer(5);
Integer b= new Integer(5);
Integer c=127;
Integer d = 127;
Integer e = 128;
Integer f = 128;
int g = 128;
System.out.println(a==b);
System.out.println(a.equals(b));
System.out.println(c == d);
System.out.println(e == f);
System.out.println(f == g);
}
}
输出结果:
false
true
true
false
true