equals与==的区别

Posted 知我者,足以

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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
    }
}

 

以上是关于equals与==的区别的主要内容,如果未能解决你的问题,请参考以下文章