久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

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

  • <small id='2nasR'></small><noframes id='2nasR'>

      <tfoot id='2nasR'></tfoot>

      • <bdo id='2nasR'></bdo><ul id='2nasR'></ul>
      1. <legend id='2nasR'><style id='2nasR'><dir id='2nasR'><q id='2nasR'></q></dir></style></legend>
      2. java的行為不一致==

        Inconsistent behavior on java#39;s ==(java的行為不一致==)
        <i id='vUSFQ'><tr id='vUSFQ'><dt id='vUSFQ'><q id='vUSFQ'><span id='vUSFQ'><b id='vUSFQ'><form id='vUSFQ'><ins id='vUSFQ'></ins><ul id='vUSFQ'></ul><sub id='vUSFQ'></sub></form><legend id='vUSFQ'></legend><bdo id='vUSFQ'><pre id='vUSFQ'><center id='vUSFQ'></center></pre></bdo></b><th id='vUSFQ'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='vUSFQ'><tfoot id='vUSFQ'></tfoot><dl id='vUSFQ'><fieldset id='vUSFQ'></fieldset></dl></div>
        <tfoot id='vUSFQ'></tfoot>

            <tbody id='vUSFQ'></tbody>
        • <small id='vUSFQ'></small><noframes id='vUSFQ'>

                <legend id='vUSFQ'><style id='vUSFQ'><dir id='vUSFQ'><q id='vUSFQ'></q></dir></style></legend>

                  <bdo id='vUSFQ'></bdo><ul id='vUSFQ'></ul>
                • 本文介紹了java的行為不一致==的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  考慮這段代碼:

                  class test {
                     public static void main(String[] args) {
                        test inst_test = new test();
                        int i1 = 2000;
                        int i2 = 2000;
                        int i3 = 2;
                        int i4 = 2;
                        Integer Ithree = new Integer(2); // 1
                        Integer Ifour = new Integer(2); // 2
                        System.out.println( Ithree == Ifour );
                        inst_test.method( i3 , i4 );
                        inst_test.method( i1 , i2 );
                     }
                     public void method( Integer i , Integer eye ) {
                        System.out.println(i == eye );
                     }
                  }
                  

                  打印出來:

                  false
                  true
                  false
                  

                  我理解第一個 false,== 運算符只檢查兩個引用是否在同一個對象上工作,在這種情況下不是.

                  I understand the first false, the == operator only checks if two references are working on the same object, which in this case aren't.

                  下面的 truefalse 讓我摸不著頭腦.為什么 Java 會認為 i3i4 相等但 i1i2 不同?兩者都被包裝成整數,不應該 both 評估為假嗎?這種不一致是否有實際原因?

                  The following true and false have me scratching my head. Why would Java consider i3 and i4 equal but i1 and i2 different? Both have been wrapped to Integer, shouldn't both evaluate to false? Is there a practical reason for this inconsistency?

                  推薦答案

                  將基元自動裝箱到對象中(在您對 method 的調用中使用的方法是使用小值緩存.來自 Java 語言規范第 5.1.7 節:

                  Autoboxing of primitives into objects (as used in your calls to method uses a cache of small values. From the Java Language Specification section 5.1.7:

                  如果被裝箱的值p為真,false,一個字節,一個字符在范圍內u0000 到 u007f,或者一個 int 或 short介于 -128 和 127 之間的數字,然后讓r1 和 r2 是任意兩個的結果p的拳擊轉換.它總是r1 == r2 的情況.

                  If the value p being boxed is true, false, a byte, a char in the range u0000 to u007f, or an int or short number between -128 and 127, then let r1 and r2 be the results of any two boxing conversions of p. It is always the case that r1 == r2.

                  緊隨其后的規范討論部分也很有趣.值得注意的是,如果 JVM 愿意,它可以緩存 更多 值 - 你不能確定這樣做的結果:

                  The discussion part of the spec immediately following that is interesting too. Notably a JVM can cache more values if it wants to - you can't be sure of the results of doing:

                  Integer i1 = 129;
                  Integer i2 = 129;
                  boolean b = (i1 == i2);
                  

                  這篇關于java的行為不一致==的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

                  【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

                  相關文檔推薦

                  How can I detect integer overflow on 32 bits int?(如何檢測 32 位 int 上的整數溢出?)
                  Local variables before return statements, does it matter?(return 語句之前的局部變量,這有關系嗎?)
                  How to convert Integer to int?(如何將整數轉換為整數?)
                  How do I create an int array with randomly shuffled numbers in a given range(如何在給定范圍內創建一個隨機打亂數字的 int 數組)
                  Why is Java able to store 0xff000000 as an int?(為什么 Java 能夠將 0xff000000 存儲為 int?)
                  Unexpected result in long/int division(意外結果導致長/整數除法)
                  <i id='4nGTx'><tr id='4nGTx'><dt id='4nGTx'><q id='4nGTx'><span id='4nGTx'><b id='4nGTx'><form id='4nGTx'><ins id='4nGTx'></ins><ul id='4nGTx'></ul><sub id='4nGTx'></sub></form><legend id='4nGTx'></legend><bdo id='4nGTx'><pre id='4nGTx'><center id='4nGTx'></center></pre></bdo></b><th id='4nGTx'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='4nGTx'><tfoot id='4nGTx'></tfoot><dl id='4nGTx'><fieldset id='4nGTx'></fieldset></dl></div>
                  • <bdo id='4nGTx'></bdo><ul id='4nGTx'></ul>
                    <legend id='4nGTx'><style id='4nGTx'><dir id='4nGTx'><q id='4nGTx'></q></dir></style></legend>
                      <tbody id='4nGTx'></tbody>

                        • <small id='4nGTx'></small><noframes id='4nGTx'>

                          <tfoot id='4nGTx'></tfoot>
                            主站蜘蛛池模板: 天天操天天玩 | 日韩三级视频 | 久久久精品视频免费 | 久久久91 | 91精品国产一区二区三区动漫 | 视频一区 亚洲 | 水蜜桃亚洲一二三四在线 | 精品国产区 | 99热视 | 国产午夜精品视频 | 久久久久久国产精品免费免费 | 亚洲中午字幕 | 求个av网址| 性色av香蕉一区二区 | 亚洲 欧美 另类 日韩 | av大片 | 国产福利在线小视频 | 日韩在线欧美 | 久久精品欧美一区二区三区不卡 | 日韩精品成人一区二区三区视频 | 91免费视频观看 | 一级黄色影片在线观看 | 午夜久久久| 成年人精品视频 | 国产精品日韩欧美一区二区 | 一区不卡在线观看 | 亚洲精品久久久久久久久久久 | 亚洲天堂久久新 | 日韩久久久久久 | 成人亚洲精品 | 精品少妇一区二区三区日产乱码 | 岛国av免费看 | 国产高清视频一区二区 | 2019中文字幕视频 | 亚洲精品视频一区二区三区 | 精品久久久久久亚洲精品 | 成人免费观看视频 | 亚洲国产成人精品女人久久久 | 久久亚洲一区 | 91精品无人区卡一卡二卡三 | 欧美视频1区 |