久久久久久久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. 主站蜘蛛池模板: 日本美女一级片 | 国产成人一区二区三区 | www.五月婷婷| 国产欧美日韩综合 | 亚洲成人日韩 | 欧美日韩视频在线 | 国产女人水真多18毛片18精品 | 四级黄色片 | 欧美日韩一区在线 | 欧美色图一区二区 | 免费h片| 一区二区在线视频 | 午夜网站在线观看 | 国产精品国产精品国产专区不卡 | 在线中文av | 精品视频在线免费 | 无套内谢的新婚少妇国语播放 | 成人免费看片&#39; | 黄色免费小视频 | 欧洲精品一区二区 | 欧美日韩一区二区三区视频 | 欧美日韩免费在线 | 久久免费视频网站 | www.日日夜夜| 黄av在线| 四虎影院永久免费 | 日韩成人综合 | 蜜桃精品噜噜噜成人av | 一级毛片在线播放 | 欧洲精品一区二区 | 成人av一区二区三区在线观看 | www.av在线播放| 日韩av手机在线 | www.久久久久 | 国产理论片在线观看 | 国产精品一级二级三级 | 日韩免费在线视频 | 死神来了4无删减版在线观看 | 黄色一级大片在线免费看国产一 | 男人添女人囗交图 | 亚洲一区在线看 |