equals与==的区别

 深入理解equals和==的区别:

代码如下:

public class IntegerTest {

    public static void main(String[] args) {
        Integer  a = new Integer(1);
        Integer b = a;
        Integer c = new Integer(1);
        System.out.println(a==b); //true
        System.out.println(a==c); //false
    }
}

 

posted @ 2017-04-14 22:39  知我者,足以  阅读(780)  评论(0编辑  收藏  举报