久久久久久久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 操作數(shù)的三元表達(dá)式的類型是什么

        What is the type of a ternary expression with int and char operands?(具有 int 和 char 操作數(shù)的三元表達(dá)式的類型是什么?)
        <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 操作數(shù)的三元表達(dá)式的類型是什么?的處理方法,對(duì)大家解決問題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

                  問題描述

                  我最近遇到了這樣一種情況,第一個(gè) syso() 字符工作正常,但在第二個(gè) 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 ?
                     }
                   }
                  

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

                  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.

                  根據(jù) JLS第 15.25.2 節(jié)(強(qiáng)調(diào)和 [] 注意我的):

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

                  數(shù)值條件表達(dá)式的類型確定如下:

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

                  • 如果第二個(gè)和第三個(gè)操作數(shù)的類型相同,那么就是條件表達(dá)式的類型.

                  ...

                  • 否則[如果上述規(guī)則都不成立],二進(jìn)制數(shù)值提升(§5.6.2)應(yīng)用于操作數(shù)類型,條件表達(dá)式的類型是第二個(gè)和第三個(gè)操作數(shù)的提升類型.

                  其中 二進(jìn)制數(shù)字促銷的相關(guān)規(guī)則是(強(qiáng)調(diào)我的):

                  加寬原語轉(zhuǎn)換(第 5.1.2 節(jié))適用于轉(zhuǎn)換以下規(guī)則中指定的一個(gè)或兩個(gè)操作數(shù):

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

                  • 如果任一操作數(shù)是 double 類型,則另一個(gè)操作數(shù)將轉(zhuǎn)換為 double.

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

                  否則,如果任一操作數(shù)為浮點(diǎn)類型,則將另一個(gè)轉(zhuǎn)換為浮點(diǎn)類型.

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

                  否則,如果其中一個(gè)操作數(shù)是 long 類型,則另一個(gè)將轉(zhuǎn)換為 long.

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

                  否則,兩個(gè)操作數(shù)都轉(zhuǎn)換為 int 類型.

                  因此在:

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

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

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

                  您必須將 m 或整個(gè)表達(dá)式顯式轉(zhuǎn)換為 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 的規(guī)則之一(我在上面省略了)是:

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

                  • 如果其中一個(gè)操作數(shù)是 T 類型,其中 T 是 byte、short 或 char,而另一個(gè)操作數(shù)是 int 類型的常量表達(dá)式(第 15.28 節(jié)),其值可在類型 T 中表示,則條件表達(dá)式是 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.

                  這篇關(guān)于具有 int 和 char 操作數(shù)的三元表達(dá)式的類型是什么?的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

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

                  相關(guān)文檔推薦

                  quot;Char cannot be dereferencedquot; error(“Char 不能被取消引用錯(cuò)誤)
                  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(讀取文本文件并存儲(chǔ)出現(xiàn)的每個(gè)字符)
                  Why do I need to explicitly cast char primitives on byte and short?(為什么我需要在 byte 和 short 上顯式轉(zhuǎn)換 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. 主站蜘蛛池模板: 视频精品一区二区三区 | 午夜一区二区三区在线观看 | 在线免费国产 | 99久久精品免费看国产小宝寻花 | 91在线精品一区二区 | 亚洲视频一区在线观看 | xxxxx黄色片 欧美一区免费 | 嫩呦国产一区二区三区av | 日韩欧美专区 | 欧美亚洲一区二区三区 | 日韩综合在线 | 婷婷久久综合 | 日韩一及片 | 亚洲一二三区免费 | 高清人人天天夜夜曰狠狠狠狠 | 欧美性生活免费 | 天天拍天天草 | 日韩免费一区二区 | 国产免费一区二区三区 | 一区二区免费看 | 久草综合在线 | 一级大片网站 | 国产98色在线 | 日韩 | 中文字幕伊人 | 亚洲深夜福利 | 国产精品久久国产精品99 | 网色| 久久综合入口 | 日日操夜夜操天天操 | 超碰导航| 亚洲视频在线观看 | 97中文视频 | 免费观看a级毛片在线播放 黄网站免费入口 | 日韩一区不卡 | 精品乱码一区二区三四区 | www.国产一区 | 久久久精品高清 | 亚洲欧美视频一区 | 国产精品久久精品 | 精品免费视频一区二区 | 久久成人精品 |