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

  • <legend id='K91HX'><style id='K91HX'><dir id='K91HX'><q id='K91HX'></q></dir></style></legend>

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

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

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

      1. Java - 為什么 char 不應該被隱式轉換為字節(和短

        Java - why does char get implicitly cast to byte (and short) primitive, when it shouldn#39;t?(Java - 為什么 char 不應該被隱式轉換為字節(和短)原語?)
        <legend id='KkKsf'><style id='KkKsf'><dir id='KkKsf'><q id='KkKsf'></q></dir></style></legend>
      2. <tfoot id='KkKsf'></tfoot>

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

                    <tbody id='KkKsf'></tbody>

                  本文介紹了Java - 為什么 char 不應該被隱式轉換為字節(和短)原語?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  編譯器的某些功能讓我感到困惑(使用 Eclipse 的 Oracle JDK 1.7).

                  Certain functionality of the compiler puzzles me (Oracle JDK 1.7 using Eclipse).

                  所以我有這本書說 char 原語需要顯式轉換為 short 和 byte,這一切都是有道理的,因為數據類型的允許范圍不重疊.

                  So I've got this book that says char primitive needs to be explicitly cast to short and byte and this all makes sense due the data types' allowed ranges don't overlap.

                  換句話說,下面的代碼可以工作(但如果沒有顯式類型轉換就無法工作):

                  In other words below code works (but wouldn't work without the explicit type casts):

                  char c = '&';  
                  byte b = (byte)c;
                  short s = (short)c;
                  

                  打印 b 或 s 正確顯示數字 38,它是 Unicode 中 (&) 的數字等價物.

                  Printing b or s correctly displays the number 38, which is the numeric equivalent of (&) in Unicode.

                  這讓我想到了我的實際問題.為什么以下方法也有效?

                  byte bc = '&';
                  short sc = '&';
                  System.out.println(bc); // Correctly displays number 38 on the console
                  System.out.println(sc); // Correctly displays number 38 on the console
                  

                  現在我肯定會理解以下內容(也可以):

                  Now I would certainly understand the following (which works too):

                  byte bt = (byte)'&';
                  System.out.println(bt); // Correctly displays number 38 on the console
                  

                  但是這種沒有編譯器警告的字符到字節(和短的)潛行轉換"對我來說似乎不合適.

                  But this no-compiler-warning char to byte (and short) "sneak conversion" doesn't seem right to me.

                  誰能解釋一下,為什么允許這樣做?

                  原因可能在于 '<char>' 本身的解釋,因此它實際上不會進入 char 原始狀態,而是作為數字(八進制或十六進制等)值?

                  Could the reason be in the interpretation of the '<char>' itself, so that it doesn't actually ever get to a char primitive state but is handled as a numeric (octal or hexadecimal etc) value?

                  推薦答案

                  基本上,賦值轉換規范指定

                  另外,如果表達式是一個常量表達式(§15.28)輸入 byte、short、char 或 int:

                  In addition, if the expression is a constant expression (§15.28) of type byte, short, char, or int:

                  如果類型為變量是 byte、short 或 char,以及常量的值表達式可以用變量的類型來表示.

                  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.

                  您的 '&' 正是 byte、short、char 或 int 類型的常量表達式".

                  這篇關于Java - 為什么 char 不應該被隱式轉換為字節(和短)原語?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

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

                  相關文檔推薦

                  quot;Char cannot be dereferencedquot; error(“Char 不能被取消引用錯誤)
                  Java Switch Statement - Is quot;orquot;/quot;andquot; possible?(Java Switch 語句 - 是“或/“和可能的?)
                  Java Replace Character At Specific Position Of String?(Java替換字符串特定位置的字符?)
                  What is the type of a ternary expression with int and char operands?(具有 int 和 char 操作數的三元表達式的類型是什么?)
                  Read a text file and store every single character occurrence(讀取文本文件并存儲出現的每個字符)
                  Why do I need to explicitly cast char primitives on byte and short?(為什么我需要在 byte 和 short 上顯式轉換 char 原語?)
                        <tbody id='ZH4CU'></tbody>

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

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

                          <bdo id='ZH4CU'></bdo><ul id='ZH4CU'></ul>
                          <legend id='ZH4CU'><style id='ZH4CU'><dir id='ZH4CU'><q id='ZH4CU'></q></dir></style></legend>

                          1. 主站蜘蛛池模板: 午夜在线视频 | 日本成年免费网站 | 欧美一级高潮片免费的 | 国产一区二区三区欧美 | 色综合色综合色综合 | 久久久久无码国产精品一区 | 国产成人免费 | 日韩精品一区二区三区中文在线 | 国产在线一区二区 | 性高朝久久久久久久3小时 av一区二区三区四区 | 国产91九色 | 成人福利在线 | 91视频进入| 毛片网站在线观看 | 午夜精品一区二区三区在线观看 | 91久久精品国产91久久 | 欧美综合国产精品久久丁香 | 亚洲午夜av久久乱码 | 欧美国产视频 | 中文字幕第一页在线 | 中文字幕日韩一区 | 成人av鲁丝片一区二区小说 | 伊人伊人| 国产精品不卡一区 | 91免费在线视频 | 国产欧美一区二区精品忘忧草 | 国外成人免费视频 | 欧美成年视频 | a免费在线 | 欧美一区二区三区一在线观看 | 亚洲精品一区二区另类图片 | 成人精品视频99在线观看免费 | 亚洲综合成人网 | 国产女人第一次做爰毛片 | 免费精品视频一区 | 精品无码久久久久久久动漫 | 草草视频在线观看 | 久久国产精品视频免费看 | 欧美伊人影院 | 亚洲福利| 欧美精品福利 |