zoukankan      html  css  js  c++  java
  • Java坑一

    public class Test {
    
        public static void main(String[] args) {
            Integer a = 12;
            Integer b = 12;
            System.out.println(a == b);
            System.out.println(a.equals(b));
            a = 128;
            b = 128;
            System.out.println(a == b);
            System.out.println(a.equals(b));
        }
    }
        /**
         * Cache to support the object identity semantics of autoboxing for values between
         * -128 and 127 (inclusive) as required by JLS.
         *
         * The cache is initialized on first usage.  The size of the cache
         * may be controlled by the -XX:AutoBoxCacheMax=<size> option.
         * During VM initialization, java.lang.Integer.IntegerCache.high property
         * may be set and saved in the private system properties in the
         * sun.misc.VM class.
         */
    
        private static class IntegerCache {
            static final int low = -128;
            static final int high;
            static final Integer cache[];
    
            static {
                // high value may be configured by property
                int h = 127;
                String integerCacheHighPropValue =
                    sun.misc.VM.getSavedProperty("java.lang.Integer.IntegerCache.high");
                if (integerCacheHighPropValue != null) {
                    int i = parseInt(integerCacheHighPropValue);
                    i = Math.max(i, 127);
                    // Maximum array size is Integer.MAX_VALUE
                    h = Math.min(i, Integer.MAX_VALUE - (-low) -1);
                }
                high = h;
    
                cache = new Integer[(high - low) + 1];
                int j = low;
                for(int k = 0; k < cache.length; k++)
                    cache[k] = new Integer(j++);
            }
    
            private IntegerCache() {}
        }
  • 相关阅读:
    django表单字段
    python3之Django表单(一)
    python3之Django模型(一)
    python3迭代器和生成器
    python3数字、日期和时间
    python3字符串与文本处理
    python3数据结构与算法
    git仓库使用
    django邮件
    python3光学字符识别模块tesserocr与pytesseract
  • 原文地址:https://www.cnblogs.com/yasepix/p/5773045.html
Copyright © 2011-2022 走看看