封装类整数类型

1:封装类整数范围

/*
     * jdk 对于整数的处理上做了一点小小的优化,
     * 在一段很小的数字区域内直接做了缓存处理,
     * 所以对于字面值直接复制小范围内是相等的,但是超过范围就不等的。127(边界值) 正好是byte范围内的数据做了处理
     */
    public static void main(String[] args) {
        

        // 位bit bytes
        
        System.out.println(Byte.MAX_VALUE);
        System.out.println(Byte.MIN_VALUE);
        Byte a = new Byte("12");
        Byte b = new Byte((byte)12);
        Byte c = 12;
        Byte d = 12;
        System.out.println(a == b);
        System.out.println(c == d);
        
        Integer e = 127;
        Integer f = 127;
        System.out.println(e == f);
        
        Integer g = -129;
        Integer k = -129;
        System.out.println(g == k);
        

2:

posted @ 2019-04-22 22:37  围攻柏林  阅读(154)  评论(0编辑  收藏  举报