<small id='BvAyQ'></small><noframes id='BvAyQ'>

      <bdo id='BvAyQ'></bdo><ul id='BvAyQ'></ul>
    <legend id='BvAyQ'><style id='BvAyQ'><dir id='BvAyQ'><q id='BvAyQ'></q></dir></style></legend>
    <i id='BvAyQ'><tr id='BvAyQ'><dt id='BvAyQ'><q id='BvAyQ'><span id='BvAyQ'><b id='BvAyQ'><form id='BvAyQ'><ins id='BvAyQ'></ins><ul id='BvAyQ'></ul><sub id='BvAyQ'></sub></form><legend id='BvAyQ'></legend><bdo id='BvAyQ'><pre id='BvAyQ'><center id='BvAyQ'></center></pre></bdo></b><th id='BvAyQ'></th></span></q></dt></tr></i><div id='BvAyQ'><tfoot id='BvAyQ'></tfoot><dl id='BvAyQ'><fieldset id='BvAyQ'></fieldset></dl></div>
    1. <tfoot id='BvAyQ'></tfoot>

        新整数与 valueOf

        New Integer vs valueOf(新整数与 valueOf)

            <legend id='O7LlY'><style id='O7LlY'><dir id='O7LlY'><q id='O7LlY'></q></dir></style></legend>
            <tfoot id='O7LlY'></tfoot>

            <small id='O7LlY'></small><noframes id='O7LlY'>

              <tbody id='O7LlY'></tbody>

                  <bdo id='O7LlY'></bdo><ul id='O7LlY'></ul>
                • <i id='O7LlY'><tr id='O7LlY'><dt id='O7LlY'><q id='O7LlY'><span id='O7LlY'><b id='O7LlY'><form id='O7LlY'><ins id='O7LlY'></ins><ul id='O7LlY'></ul><sub id='O7LlY'></sub></form><legend id='O7LlY'></legend><bdo id='O7LlY'><pre id='O7LlY'><center id='O7LlY'></center></pre></bdo></b><th id='O7LlY'></th></span></q></dt></tr></i><div id='O7LlY'><tfoot id='O7LlY'></tfoot><dl id='O7LlY'><fieldset id='O7LlY'></fieldset></dl></div>
                  本文介绍了新整数与 valueOf的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我使用 Sonar 来使我的代码更清晰,它指出我正在使用 新的 Integer(1) 而不是 Integer.valueOf(1).因为似乎 valueOf 没有实例化一个新对象,所以对内存更友好.valueOf 如何不实例化一个新对象?它是如何工作的?对所有整数都是这样吗?

                  I was using Sonar to make my code cleaner, and it pointed out that I'm using new Integer(1) instead of Integer.valueOf(1). Because it seems that valueOf does not instantiate a new object so is more memory-friendly. How can valueOf not instantiate a new object? How does it work? Is this true for all integers?

                  推荐答案

                  Integer.valueOf-128+127 的值实现缓存代码>.请参阅 Java 语言规范的最后一段,第 5.1.7 节,它解释了装箱的要求(通常根据 .valueOf 方法实现).

                  Integer.valueOf implements a cache for the values -128 to +127. See the last paragraph of the Java Language Specification, section 5.1.7, which explains the requirements for boxing (usually implemented in terms of the .valueOf methods).

                  http:///docs.oracle.com/javase/specs/jls/se7/html/jls-5.html#jls-5.1.7

                  这篇关于新整数与 valueOf的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  How to send data to COM PORT using JAVA?(如何使用 JAVA 向 COM PORT 发送数据?)
                  How to make a report page direction to change to quot;rtlquot;?(如何使报表页面方向更改为“rtl?)
                  Use cyrillic .properties file in eclipse project(在 Eclipse 项目中使用西里尔文 .properties 文件)
                  Is there any way to detect an RTL language in Java?(有没有办法在 Java 中检测 RTL 语言?)
                  How to load resource bundle messages from DB in Java?(如何在 Java 中从 DB 加载资源包消息?)
                  How do I change the default locale settings in Java to make them consistent?(如何更改 Java 中的默认语言环境设置以使其保持一致?)
                    <tbody id='bOP2H'></tbody>
                    <legend id='bOP2H'><style id='bOP2H'><dir id='bOP2H'><q id='bOP2H'></q></dir></style></legend>
                  • <small id='bOP2H'></small><noframes id='bOP2H'>

                  • <i id='bOP2H'><tr id='bOP2H'><dt id='bOP2H'><q id='bOP2H'><span id='bOP2H'><b id='bOP2H'><form id='bOP2H'><ins id='bOP2H'></ins><ul id='bOP2H'></ul><sub id='bOP2H'></sub></form><legend id='bOP2H'></legend><bdo id='bOP2H'><pre id='bOP2H'><center id='bOP2H'></center></pre></bdo></b><th id='bOP2H'></th></span></q></dt></tr></i><div id='bOP2H'><tfoot id='bOP2H'></tfoot><dl id='bOP2H'><fieldset id='bOP2H'></fieldset></dl></div>
                  • <tfoot id='bOP2H'></tfoot>

                          • <bdo id='bOP2H'></bdo><ul id='bOP2H'></ul>