久久久久久久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ò)誤消息“類型不匹配:無法

        Java: why do I receive the error message quot;Type mismatch: cannot convert int to bytequot;(Java:為什么我會(huì)收到錯(cuò)誤消息“類型不匹配:無法將 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ò)誤消息“類型不匹配:無法將 int 轉(zhuǎn)換為字節(jié)"?的處理方法,對大家解決問題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

                  問題描述

                  如果您聲明 byte 或 short 類型的變量并嘗試對它們執(zhí)行算術(shù)運(yùn)算,則會(huì)收到錯(cuò)誤類型不匹配:無法將 int 轉(zhuǎn)換為 short"(或相應(yīng)地類型不匹配:無法將 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)算符被定義為對任何數(shù)字類型進(jìn)行操作,但根據(jù) Java 語言規(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.

                  要對 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 不允許對這些類型進(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)算符.因此,要對字節(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ò)誤消息“類型不匹配:無法將 int 轉(zhuǎn)換為字節(jié)"?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

                  【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請聯(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替換字符串特定位置的字符?)
                  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 原語?)
                  <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>

                          • 主站蜘蛛池模板: 日韩乱码在线 | 国产精品一区二区三 | 久久国产美女视频 | 亚洲一区二区三区在线视频 | 国产精品久久亚洲 | 欧美日韩视频一区二区 | 国产欧美一区二区三区在线看 | 美女爽到呻吟久久久久 | 欧美视频第二页 | 一区二区三区国产在线观看 | 中文字幕在线观看第一页 | 精品视频在线免费观看 | 精品国产乱码 | 日韩精品网站 | 国产在线中文 | 91麻豆产精品久久久久久 | 日韩一区二区av | 日韩一区二区福利 | 欧美一区二区在线 | 视频在线观看亚洲 | 亚洲 欧美 在线 一区 | av综合站| 成人一区二区三区在线 | 久久久久香蕉视频 | 久久久综合网 | 久久久久国产一级毛片高清网站 | 日韩亚洲视频 | 欧美综合一区二区 | 秋霞影院一区二区 | 一本色道精品久久一区二区三区 | 国产精品久久久一区二区三区 | 亚洲三区在线 | 日韩精品一区二区在线观看 | 成人欧美一区二区三区黑人孕妇 | 精品视频在线播放 | 精品国产乱码久久久久久影片 | 激情一区二区三区 | 日韩成人专区 | 久久在线 | 91九色porny首页最多播放 | 99爱视频|