久久久久久久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的行為不一致==的處理方法,對(duì)大家解決問(wèn)題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)吧!

                  問(wèn)題描述

                  考慮這段代碼:

                  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 );
                     }
                  }
                  

                  打印出來(lái):

                  false
                  true
                  false
                  

                  我理解第一個(gè) false,== 運(yùn)算符只檢查兩個(gè)引用是否在同一個(gè)對(duì)象上工作,在這種情況下不是.

                  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 會(huì)認(rèn)為 i3i4 相等但 i1i2 不同?兩者都被包裝成整數(shù),不應(yīng)該 both 評(píng)估為假嗎?這種不一致是否有實(shí)際原因?

                  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?

                  推薦答案

                  將基元自動(dòng)裝箱到對(duì)象中(在您對(duì) method 的調(diào)用中使用的方法是使用小值緩存.來(lái)自 Java 語(yǔ)言規(guī)范第 5.1.7 節(jié):

                  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,一個(gè)字節(jié),一個(gè)字符在范圍內(nèi)u0000 到 u007f,或者一個(gè) int 或 short介于 -128 和 127 之間的數(shù)字,然后讓r1 和 r2 是任意兩個(gè)的結(jié)果p的拳擊轉(zhuǎn)換.它總是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.

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

                  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);
                  

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

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

                  相關(guān)文檔推薦

                  How can I detect integer overflow on 32 bits int?(如何檢測(cè) 32 位 int 上的整數(shù)溢出?)
                  Local variables before return statements, does it matter?(return 語(yǔ)句之前的局部變量,這有關(guān)系嗎?)
                  How to convert Integer to int?(如何將整數(shù)轉(zhuǎn)換為整數(shù)?)
                  How do I create an int array with randomly shuffled numbers in a given range(如何在給定范圍內(nèi)創(chuàng)建一個(gè)隨機(jī)打亂數(shù)字的 int 數(shù)組)
                  Why is Java able to store 0xff000000 as an int?(為什么 Java 能夠?qū)?0xff000000 存儲(chǔ)為 int?)
                  Unexpected result in long/int division(意外結(jié)果導(dǎo)致長(zhǎng)/整數(shù)除法)
                  <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>
                            主站蜘蛛池模板: 欧美乱操| 国产精品视频观看 | 99re视频| 国产成人网 | 99在线免费观看视频 | 亚洲在线一区二区 | 一本色道精品久久一区二区三区 | 国产综合视频 | www免费视频 | 97精品超碰一区二区三区 | 天天玩天天干天天操 | 91久久精品国产91久久 | 古装三级在线播放 | 日韩中文字幕视频在线 | 草久在线视频 | 性高湖久久久久久久久aaaaa | 91九色porny首页最多播放 | 久久久123 | 欧美精品久久 | 午夜亚洲| 美女黄频 | 毛片一区 | 日日干干 | 成人在线精品视频 | 亚洲精品一区二区三区免 | 欧美日韩精品区 | 国产视频中文字幕 | 亚洲一区免费在线 | 一区二区三区高清在线观看 | 中午字幕在线观看 | 国产jizz女人多喷水99 | 四虎海外 | 亚洲精品黄色 | 国产一区二区三区久久久久久久久 | 国产精品久久久久无码av | 四虎影院久久 | 青青久在线视频 | 亚洲精品一区中文字幕 | 亚洲欧美激情精品一区二区 | 在线免费观看成年人视频 | 日本在线视频中文字幕 |