使用自动拆箱和装箱要注意

版权声明:原创文章,转载需注明转载出处! https://blog.csdn.net/zhoumingsong123/article/details/82560324
package com.company;

public class Main {

    public static void main(String[] args) {
        Integer a = 1;
        Integer b = 2;
        Integer c = 3;
        Integer d = 3;
        Integer e = 5;
        Integer f = 5;
        Long g = 3L;
        System.out.println(c == d);
        System.out.println(e == f);
        System.out.println(c == (a + b));
        System.out.println(c.equals(a + b));
        System.out.println(g == (a + b));
        System.out.println(g.equals(a + b));

        //true
        //true
        //true
        //true
       // true
        //false  不支持类型转换
    }
}

猜你喜欢

转载自blog.csdn.net/zhoumingsong123/article/details/82560324