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

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

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

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

        Java:整數等于 vs. ==

        Java: Integer equals vs. ==(Java:整數等于 vs. ==)
          <tbody id='unonn'></tbody>

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

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

                  本文介紹了Java:整數等于 vs. ==的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  從 Java 1.5 開始,您幾乎可以在許多情況下將 Integerint 互換.

                  As of Java 1.5, you can pretty much interchange Integer with int in many situations.

                  但是,我發現我的代碼中有一個潛在的缺陷,這讓我有點吃驚.

                  However, I found a potential defect in my code that surprised me a bit.

                  以下代碼:

                  Integer cdiCt = ...;
                  Integer cdsCt = ...;
                  ...
                  if (cdiCt != null && cdsCt != null && cdiCt != cdsCt)
                      mismatch = true;
                  

                  當值相等時,似乎錯誤地設置了不匹配,盡管我無法確定在什么情況下.我在 Eclipse 中設置了一個斷點,發現 Integer 的值都是 137,我檢查了布爾表達式,它說它是假的,但是當我越過它時,它將不匹配設置為真.

                  appeared to be incorrectly setting mismatch when the values were equal, although I can't determine under what circumstances. I set a breakpoint in Eclipse and saw that the Integer values were both 137, and I inspected the boolean expression and it said it was false, but when I stepped over it, it was setting mismatch to true.

                  將條件更改為:

                  if (cdiCt != null && cdsCt != null && !cdiCt.equals(cdsCt))
                  

                  解決了問題.

                  誰能解釋一下為什么會這樣?到目前為止,我只在我自己的 PC 上的本地主機上看到了這種行為.在這種特殊情況下,代碼成功通過了大約 20 次比較,但在 2 次比較失敗.問題始終可以重現.

                  Can anyone shed some light on why this happened? So far, I have only seen the behavior on my localhost on my own PC. In this particular case, the code successfully made it past about 20 comparisons, but failed on 2. The problem was consistently reproducible.

                  如果這是一個普遍存在的問題,它應該會導致我們的其他環境(開發和測試)出現錯誤,但到目前為止,在執行此代碼片段的數百次測試之后,沒有人報告此問題.

                  If it is a prevalent problem, it should be causing errors on our other environments (dev and test), but so far, no one has reported the problem after hundreds of tests executing this code snippet.

                  使用 == 比較兩個 Integer 值仍然不合法嗎?

                  Is it still not legitimate to use == to compare two Integer values?

                  除了下面所有的好答案之外,下面的 stackoverflow 鏈接還有很多額外的信息.它實際上會回答我原來的問題,但是因為我沒有在我的問題中提到自動裝箱,所以它沒有出現在選定的建議中:

                  In addition to all the fine answers below, the following stackoverflow link has quite a bit of additional information. It actually would have answered my original question, but because I didn't mention autoboxing in my question, it didn't show up in the selected suggestions:

                  為什么編譯器/JVM就不能讓自動裝箱正常工作"?

                  推薦答案

                  JVM 正在緩存整數值.因此,與 == 的比較僅適用于 -128 到 127 之間的數字.

                  The JVM is caching Integer values. Hence the comparison with == only works for numbers between -128 and 127.

                  參考:#Immutable_Objects_.2F_Wrapper_Class_Caching

                  這篇關于Java:整數等于 vs. ==的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持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 數組)
                  Inconsistent behavior on java#39;s ==(java的行為不一致==)
                  Why is Java able to store 0xff000000 as an int?(為什么 Java 能夠將 0xff000000 存儲為 int?)
                1. <small id='trNIQ'></small><noframes id='trNIQ'>

                    <tbody id='trNIQ'></tbody>

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

                      • <bdo id='trNIQ'></bdo><ul id='trNIQ'></ul>
                            <legend id='trNIQ'><style id='trNIQ'><dir id='trNIQ'><q id='trNIQ'></q></dir></style></legend>
                          • 主站蜘蛛池模板: 人人草人人干 | 欧美二级| 精品av | 欧美一区二区三区国产精品 | 瑞克和莫蒂第五季在线观看 | 草草视频在线观看 | 精品视频网 | 精品视频一区二区三区在线观看 | 亚洲 欧美 另类 综合 偷拍 | 午夜影院在线观看版 | 久久久夜 | 久久久久久亚洲精品 | 国产最好的av国产大片 | 精品视频一区二区三区在线观看 | 精品视频一区二区三区在线观看 | 一区二区精品 | 爱爱免费视频 | 人人擦人人干 | 精品视频在线播放 | 久久福利电影 | 免费网站国产 | 黄色毛片在线看 | 二区国产 | 成人3d动漫一区二区三区91 | 亚洲三级国产 | 久久国产成人 | 国产精品不卡一区 | 黄色网址在线免费播放 | 国产精品免费高清 | 高清黄色网址 | 日韩欧美国产精品综合嫩v 一区中文字幕 | 精品免费国产一区二区三区 | 精品一区在线 | 亚洲一区二区三区在线播放 | 亚洲国产欧美日韩 | 一区二区不卡 | 免费a网站 | 国产一区二区三区色淫影院 | 九九久久这里只有精品 | 精品入口麻豆88视频 | 香蕉久久a毛片 |