Java中int,Integer,equals,==的區別

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);

}

}

輸出結果:

false
true
true
false
true

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章