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

    1. <legend id='56IpO'><style id='56IpO'><dir id='56IpO'><q id='56IpO'></q></dir></style></legend>

      <small id='56IpO'></small><noframes id='56IpO'>

        <bdo id='56IpO'></bdo><ul id='56IpO'></ul>

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

    3. 為什么我不能添加兩個字節并獲得一個 int,而我

      Why can not I add two bytes and get an int and I can add two final bytes get a byte?(為什么我不能添加兩個字節并獲得一個 int,而我可以添加兩個最終字節獲得一個字節?) - IT屋-程序員軟件開發技術分享社
        <tbody id='9Ibyl'></tbody>
        <i id='9Ibyl'><tr id='9Ibyl'><dt id='9Ibyl'><q id='9Ibyl'><span id='9Ibyl'><b id='9Ibyl'><form id='9Ibyl'><ins id='9Ibyl'></ins><ul id='9Ibyl'></ul><sub id='9Ibyl'></sub></form><legend id='9Ibyl'></legend><bdo id='9Ibyl'><pre id='9Ibyl'><center id='9Ibyl'></center></pre></bdo></b><th id='9Ibyl'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='9Ibyl'><tfoot id='9Ibyl'></tfoot><dl id='9Ibyl'><fieldset id='9Ibyl'></fieldset></dl></div>
          <bdo id='9Ibyl'></bdo><ul id='9Ibyl'></ul>

            <tfoot id='9Ibyl'></tfoot>

            <small id='9Ibyl'></small><noframes id='9Ibyl'>

          • <legend id='9Ibyl'><style id='9Ibyl'><dir id='9Ibyl'><q id='9Ibyl'></q></dir></style></legend>
                本文介紹了為什么我不能添加兩個字節并獲得一個 int,而我可以添加兩個最終字節獲得一個字節?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                問題描述

                public class Java{
                    public static void main(String[] args){
                        final byte x = 1;
                        final byte y = 2;
                        byte z = x + y;//ok
                        System.out.println(z);
                
                        byte a = 1;
                        byte b = 2;
                        byte c = a + b; //Compiler error
                        System.out.println(c);
                    }
                }
                

                如果涉及任何 int 大小或更小的表達式的結果始終是 int,即使兩個字節的總和適合一個字節.

                If the result of an expression involving anything int-sized or smaller is always an int even if the sum of two bytes fit in a byte.

                為什么當我們添加兩個適合一個字節的最終字節時會發生這種情況?沒有編譯器錯誤.

                推薦答案

                來自JLS 5.2 賦值轉換

                此外,如果表達式是 byte、short、char 或 int 類型的常量表達式(第 15.28 節):- 如果類型為變量是 byte、short 或 char,以及常量的值表達式可以用變量的類型來表示.

                In addition, if the expression is a constant expression (§15.28) of type byte, short, char, or int: - A narrowing primitive conversion may be used if the type of the variable is byte, short, or char, and the value of the constant expression is representable in the type of the variable.

                簡而言之,表達式的值(在編譯時是已知的,因為它是一個常量表達式)可以用字節變量的類型來表示.

                In short the value of the expression (which is known at compile time, because it is a constant expression) is representable in the type of the variable that is byte.

                考慮你的表達方式

                 final byte x = 1;
                 final byte y = 2;
                 byte z = x + y;//This is constant expression and value is known at compile time
                

                因此,當求和適合字節時,它不會引發編譯錯誤.

                So as summation fits into byte it does not raise an compilation error.

                如果你這樣做了

                final byte x = 100;
                final byte y = 100;
                byte z = x + y;// Compilation error it no longer fits in byte
                

                這篇關于為什么我不能添加兩個字節并獲得一個 int,而我可以添加兩個最終字節獲得一個字節?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持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?)

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

                        <tbody id='OW0BS'></tbody>
                        <bdo id='OW0BS'></bdo><ul id='OW0BS'></ul>
                        <legend id='OW0BS'><style id='OW0BS'><dir id='OW0BS'><q id='OW0BS'></q></dir></style></legend>
                          <i id='OW0BS'><tr id='OW0BS'><dt id='OW0BS'><q id='OW0BS'><span id='OW0BS'><b id='OW0BS'><form id='OW0BS'><ins id='OW0BS'></ins><ul id='OW0BS'></ul><sub id='OW0BS'></sub></form><legend id='OW0BS'></legend><bdo id='OW0BS'><pre id='OW0BS'><center id='OW0BS'></center></pre></bdo></b><th id='OW0BS'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='OW0BS'><tfoot id='OW0BS'></tfoot><dl id='OW0BS'><fieldset id='OW0BS'></fieldset></dl></div>
                          <tfoot id='OW0BS'></tfoot>
                        1. 主站蜘蛛池模板: 超碰在线亚洲 | 免费激情av | 国产精品视频一 | 欧美精品成人影院 | 亚洲国产精品一区二区第一页 | 精品av | 欧美区在线 | 欧美乱码精品一区二区三区 | 久久久久亚洲精品中文字幕 | 视频精品一区 | 欧美成人自拍 | 欧美久久一区二区 | 久久综合亚洲 | 一级毛片在线播放 | 成人高清网站 | 日韩精品1区2区3区 国产精品国产成人国产三级 | 综合久| 国产成人综合亚洲欧美94在线 | 国产中文 | 精品久久久久久久久久久久 | 黄色在线免费播放 | www.久久久久久久久 | 999精品在线观看 | 国产1区在线| 国产欧美精品 | 91视频进入 | 日韩欧美在线视频一区 | 亚洲精品乱码 | 日日操夜夜摸 | 精品婷婷 | 久色激情 | 午夜播放器在线观看 | 亚洲一区二区久久 | 91视频免费 | 99欧美精品 | 欧产日产国产精品v | 久久久久久久av | av中文字幕在线观看 | 久久国产成人 | 日韩 欧美 二区 | 韩日在线视频 |