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

<tfoot id='k8Vit'></tfoot>
    • <bdo id='k8Vit'></bdo><ul id='k8Vit'></ul>

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

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

      1. Java:為什么我會(huì)收到錯(cuò)誤消息“類型不匹配:無(wú)法

        Java: why do I receive the error message quot;Type mismatch: cannot convert int to bytequot;(Java:為什么我會(huì)收到錯(cuò)誤消息“類型不匹配:無(wú)法將 int 轉(zhuǎn)換為字節(jié)?)
          <tfoot id='Gg4Pp'></tfoot>
          • <bdo id='Gg4Pp'></bdo><ul id='Gg4Pp'></ul>

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

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

                  本文介紹了Java:為什么我會(huì)收到錯(cuò)誤消息“類型不匹配:無(wú)法將 int 轉(zhuǎn)換為字節(jié)"?的處理方法,對(duì)大家解決問題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

                  問題描述

                  如果您聲明 byte 或 short 類型的變量并嘗試對(duì)它們執(zhí)行算術(shù)運(yùn)算,則會(huì)收到錯(cuò)誤類型不匹配:無(wú)法將 int 轉(zhuǎn)換為 short"(或相應(yīng)地類型不匹配:無(wú)法將 int 轉(zhuǎn)換為字節(jié)").

                  If you declare variables of type byte or short and attempt to perform arithmetic operations on these, you receive the error "Type mismatch: cannot convert int to short" (or correspondingly "Type mismatch: cannot convert int to byte").

                  byte a = 23;
                  byte b = 34;
                  byte c = a + b;
                  

                  在這個(gè)例子中,編譯錯(cuò)誤在第三行.

                  In this example, the compile error is on the third line.

                  推薦答案

                  雖然算術(shù)運(yùn)算符被定義為對(duì)任何數(shù)字類型進(jìn)行操作,但根據(jù) Java 語(yǔ)言規(guī)范(5.6.2 Binary Numeric Promotion),字節(jié)和短類型的操作數(shù)在交給操作員之前會(huì)自動(dòng)提升為 int.

                  Although the arithmetic operators are defined to operate on any numeric type, according the Java language specification (5.6.2 Binary Numeric Promotion), operands of type byte and short are automatically promoted to int before being handed to the operators.

                  要對(duì) byte 或 short 類型的變量執(zhí)行算術(shù)運(yùn)算,您必須將表達(dá)式括在括號(hào)中(其中的運(yùn)算將作為 int 類型執(zhí)行),然后將結(jié)果轉(zhuǎn)換回所需的類型.

                  To perform arithmetic operations on variables of type byte or short, you must enclose the expression in parentheses (inside of which operations will be carried out as type int), and then cast the result back to the desired type.

                  byte a = 23;
                  byte b = 34;
                  byte c = (byte) (a + b);

                  下面是給真正的 Java 大師的后續(xù)問題:為什么?byte 和 short 類型是非常好的數(shù)字類型.為什么 Java 不允許對(duì)這些類型進(jìn)行直接算術(shù)運(yùn)算?(答案不是精度損失",因?yàn)槭紫葲]有明顯的理由轉(zhuǎn)換為 int.)

                  Here's a follow-on question to the real Java gurus: why? The types byte and short are perfectly fine numeric types. Why does Java not allow direct arithmetic operations on these types? (The answer is not "loss of precision", as there is no apparent reason to convert to int in the first place.)

                  更新:jrudolph 建議此行為基于 JVM 中可用的操作,具體而言,僅實(shí)現(xiàn)全字和雙字運(yùn)算符.因此,要對(duì)字節(jié)和短褲進(jìn)行操作,必須將它們轉(zhuǎn)換為 int.

                  Update: jrudolph suggests that this behavior is based on the operations available in the JVM, specifically, that only full- and double-word operators are implemented. Hence, to operator on bytes and shorts, they must be converted to int.

                  這篇關(guān)于Java:為什么我會(huì)收到錯(cuò)誤消息“類型不匹配:無(wú)法將 int 轉(zhuǎn)換為字節(jié)"?的文章就介紹到這了,希望我們推薦的答案對(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 語(yǔ)句 - 是“或/“和可能的?)
                  Java Replace Character At Specific Position Of String?(Java替換字符串特定位置的字符?)
                  What is the type of a ternary expression with int and char operands?(具有 int 和 char 操作數(shù)的三元表達(dá)式的類型是什么?)
                  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 原語(yǔ)?)
                  <tfoot id='KYt9J'></tfoot>
                  <i id='KYt9J'><tr id='KYt9J'><dt id='KYt9J'><q id='KYt9J'><span id='KYt9J'><b id='KYt9J'><form id='KYt9J'><ins id='KYt9J'></ins><ul id='KYt9J'></ul><sub id='KYt9J'></sub></form><legend id='KYt9J'></legend><bdo id='KYt9J'><pre id='KYt9J'><center id='KYt9J'></center></pre></bdo></b><th id='KYt9J'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='KYt9J'><tfoot id='KYt9J'></tfoot><dl id='KYt9J'><fieldset id='KYt9J'></fieldset></dl></div>

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

                    <bdo id='KYt9J'></bdo><ul id='KYt9J'></ul>

                          • <legend id='KYt9J'><style id='KYt9J'><dir id='KYt9J'><q id='KYt9J'></q></dir></style></legend>
                              <tbody id='KYt9J'></tbody>

                          • 主站蜘蛛池模板: 国产精品xxxx | 中文在线a在线 | 欧美午夜精品理论片a级按摩 | 日韩久草| 国产精品美女久久久久 | 国产精品一区二区三区四区 | 久草在线视频中文 | 国产成人综合av | 黑人精品xxx一区一二区 | 国产原创视频 | 中文字幕在线观看一区 | 日批日韩在线观看 | 国产在线观看网站 | 国产成人精品一区二区三区四区 | 国产日韩欧美一区 | 午夜精品久久久久久久久久久久久 | 成人免费淫片aa视频免费 | 精品国产乱码久久久久久蜜柚 | 男女视频在线免费观看 | 91精品一区二区 | 99精品视频一区二区三区 | 久久精品日产第一区二区三区 | 成人免费视频一区 | 在线国产一区 | 69热视频在线观看 | 一区二区三区网站 | 91久久国产综合久久91精品网站 | 91av视频在线观看 | 欧美色性 | 成年免费大片黄在线观看岛国 | 日韩aⅴ在线观看 | 91av在线免费 | 精品亚洲一区二区 | 久久精品色欧美aⅴ一区二区 | 亚洲成av人片在线观看无码 | 人人种亚洲 | 国产毛片毛片 | 久久久久久久久久久一区二区 | 激情一区二区三区 | 超碰成人免费 | 99re免费 |