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

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

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

    <tfoot id='NnGUf'></tfoot>

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

        具有 int 和 char 操作數的三元表達式的類型是什么

        What is the type of a ternary expression with int and char operands?(具有 int 和 char 操作數的三元表達式的類型是什么?)
        <legend id='cSqkJ'><style id='cSqkJ'><dir id='cSqkJ'><q id='cSqkJ'></q></dir></style></legend>
          <tfoot id='cSqkJ'></tfoot>
          • <bdo id='cSqkJ'></bdo><ul id='cSqkJ'></ul>
                  <tbody id='cSqkJ'></tbody>
                <i id='cSqkJ'><tr id='cSqkJ'><dt id='cSqkJ'><q id='cSqkJ'><span id='cSqkJ'><b id='cSqkJ'><form id='cSqkJ'><ins id='cSqkJ'></ins><ul id='cSqkJ'></ul><sub id='cSqkJ'></sub></form><legend id='cSqkJ'></legend><bdo id='cSqkJ'><pre id='cSqkJ'><center id='cSqkJ'></center></pre></bdo></b><th id='cSqkJ'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='cSqkJ'><tfoot id='cSqkJ'></tfoot><dl id='cSqkJ'><fieldset id='cSqkJ'></fieldset></dl></div>

                1. <small id='cSqkJ'></small><noframes id='cSqkJ'>

                  本文介紹了具有 int 和 char 操作數的三元表達式的類型是什么?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  我最近遇到了這樣一種情況,第一個 syso() 字符工作正常,但在第二個 syso() 中它正在打印 ASCII 代碼.

                  I recently come accross the scenario where in first syso() charcter is working fine but in second syso() it is printing ASCII code.

                  public class Test{
                  public static void main(String[] args) {
                      char x = 'A';
                      char y= 'B';
                      int m = 0;
                  
                      System.out.println(true  ? x : 0);//Working fine prints A
                      System.out.println(true  ? y : 0);//Working fine prints B
                      System.out.println(false ? 0 : y);//Working fine prints B
                      System.out.println(false ? m : x);// Here it prints 65 why ?
                     }
                   }
                  

                  我真的很想知道為什么它在第二個 syso() 中打印 ascii 代碼?請幫忙

                  I really want to know why it is printing ascii code in second syso() ? Please help

                  推薦答案

                  問題出在 false 的類型上?m : x,最終是 int,而不是 char.

                  The issue is in the type of false ? m : x, which ends up being int, not char.

                  根據 JLS第 15.25.2 節(強調和 [] 注意我的):

                  As per JLS section 15.25.2 (emphasis and [] note mine):

                  數值條件表達式的類型確定如下:

                  The type of a numeric conditional expression is determined as follows:

                  • 如果第二個和第三個操作數的類型相同,那么就是條件表達式的類型.

                  ...

                  • 否則[如果上述規則都不成立],二進制數值提升(§5.6.2)應用于操作數類型,條件表達式的類型是第二個和第三個操作數的提升類型.

                  其中 二進制數字促銷的相關規則是(強調我的):

                  加寬原語轉換(第 5.1.2 節)適用于轉換以下規則中指定的一個或兩個操作數:

                  Widening primitive conversion (§5.1.2) is applied to convert either or both operands as specified by the following rules:

                  • 如果任一操作數是 double 類型,則另一個操作數將轉換為 double.

                  • If either operand is of type double, the other is converted to double.

                  否則,如果任一操作數為浮點類型,則將另一個轉換為浮點類型.

                  Otherwise, if either operand is of type float, the other is converted to float.

                  否則,如果其中一個操作數是 long 類型,則另一個將轉換為 long.

                  Otherwise, if either operand is of type long, the other is converted to long.

                  否則,兩個操作數都轉換為 int 類型.

                  因此在:

                  char x = ...;
                  int m = ...;
                  

                  表達式條件?m : x 被提升為 intSystem.out.println(int) 被調用,并將其打印為數字.

                  The expression condition ? m : x is promoted to int, and System.out.println(int) is called, and it prints it as a number.

                  您必須將 m 或整個表達式顯式轉換為 char,例如:

                  You'd have to explicitly cast m or the whole expression to a char, e.g.:

                  System.out.println((char)(false ? m : x));
                  

                  或者:

                  System.out.println(false ? (char)m : x);
                  

                  至于你的條件?x : 0條件 ?0 : x 形式,15.25.2 的規則之一(我在上面省略了)是:

                  As for your condition ? x : 0 and condition ? 0 : x forms, one of the rules (that I omitted above) from 15.25.2 is:

                  • 如果其中一個操作數是 T 類型,其中 T 是 byte、short 或 char,而另一個操作數是 int 類型的常量表達式(第 15.28 節),其值可在類型 T 中表示,則條件表達式是 T.

                  0 符合此描述.xchar,0 適合 char,因此條件的類型是 char 和字符被打印出來了.

                  0 fits this description. x is a char, 0 fits in a char, the type of the conditional is therefore char and the character is printed.

                  這篇關于具有 int 和 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替換字符串特定位置的字符?)
                  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 原語?)
                  What#39;s the best way to check if a character is a vowel in Java?(在 Java 中檢查字符是否為元音的最佳方法是什么?)
                  <i id='o6TxC'><tr id='o6TxC'><dt id='o6TxC'><q id='o6TxC'><span id='o6TxC'><b id='o6TxC'><form id='o6TxC'><ins id='o6TxC'></ins><ul id='o6TxC'></ul><sub id='o6TxC'></sub></form><legend id='o6TxC'></legend><bdo id='o6TxC'><pre id='o6TxC'><center id='o6TxC'></center></pre></bdo></b><th id='o6TxC'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='o6TxC'><tfoot id='o6TxC'></tfoot><dl id='o6TxC'><fieldset id='o6TxC'></fieldset></dl></div>

                    1. <small id='o6TxC'></small><noframes id='o6TxC'>

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

                        <tfoot id='o6TxC'></tfoot>

                          1. 主站蜘蛛池模板: 久久乐国产精品 | 国产一卡二卡三卡 | 国产精品久久精品 | 亚洲最新在线视频 | 蜜桃特黄a∨片免费观看 | 超碰97人人人人人蜜桃 | 亚洲视频在线播放 | 亚洲午夜视频 | 福利网址 | 中文字幕 国产 | 午夜寂寞影院列表 | 一级片片 | 亚洲成人自拍网 | 免费在线看a | 偷拍亚洲色图 | 久久99国产精一区二区三区 | 精品毛片在线观看 | 五月婷婷视频 | 久久久久久久久久久国产 | 看av片网站| 亚洲成人av在线播放 | 成人精品国产免费网站 | 欧美日韩亚洲国产 | 欧美日韩免费 | 国产成人精品在线 | 日韩一区不卡 | 亚洲国产成人久久久 | 国产精品毛片一区二区三区 | 天堂影院av | 国产精品亚洲欧美日韩一区在线 | 亚洲午夜电影 | 蜜桃视频成人 | 欧美日韩黄色一级片 | 久久久精品视频一区二区三区 | 色吧久久 | 伊人伊成久久人综合网站 | 国产综合视频 | 国产一级一级毛片 | 国产特级毛片 | 亚洲视频在线播放 | 亚洲一区二区三区在线 |