pbootcms网站模板|日韩1区2区|织梦模板||网站源码|日韩1区2区|jquery建站特效-html5模板网

    <tfoot id='6mv88'></tfoot>
    • <bdo id='6mv88'></bdo><ul id='6mv88'></ul>

        <small id='6mv88'></small><noframes id='6mv88'>

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

        Java char 也是 int 嗎?

        Java char is also an int?(Java char 也是 int 嗎?)

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

                • 本文介紹了Java char 也是 int 嗎?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  我正在嘗試為課程完成一些代碼:

                  I was trying to get some code done for class:

                  public int getValue(char value) {
                      if (value == 'y') return this.y;
                      else if (value == 'x') return this.x;
                  

                  由于我最終可能無法返回任何東西,所以它告訴我最后要這樣做:

                  Since I might not be able to return anything in the end, it told me to do this at the end:

                  return value;
                  

                  這讓我很驚訝,因為該方法的返回類型是 int 類型.然而,它告訴我返回一個 char!我正在使用 eclipse,并且習慣了無窮無盡的警告和東西,這是一個重大的驚喜.

                  This surprised me because the return type for the method was of type int. Yet, it was telling me to return a char! I'm using eclipse, and accustomed to the endless number of warnings and stuff, this was a major surprise.

                  那么,char 真的是 int 嗎?為什么會這樣?

                  So, is a char really an int? Why is this happening?

                  推薦答案

                  Java 語言規范 狀態

                  當帶有 Expression 的 return 語句出現在方法中時聲明,Expression 必須 可分配(第 5.2 節) 到聲明的方法的返回類型,或發生編譯時錯誤.

                  When a return statement with an Expression appears in a method declaration, the Expression must be assignable (§5.2) to the declared return type of the method, or a compile-time error occurs.

                  控制一個值是否可分配給另一個值的規則定義為

                  where the rules governing whether one value is assignable to another is defined as

                  賦值上下文允許使用以下之一:

                  Assignment contexts allow the use of one of the following:

                  • 擴大原語轉換(§5.1.2)

                  原始類型的 19 種特定轉換稱為擴展原始轉換:

                  19 specific conversions on primitive types are called the widening primitive conversions:

                  • charint、long、float 或 `double
                  • char to int, long, float, or `double

                  最后

                  擴展原語轉換不會丟失有關在下列情況下,數值的總大小,其中數值被完全保留:[...]

                  A widening primitive conversion does not lose information about the overall magnitude of a numeric value in the following cases, where the numeric value is preserved exactly: [...]

                  char 到整數類型 T 的擴展轉換將零擴展char 值的表示以填充更寬的格式.

                  A widening conversion of a char to an integral type T zero-extends the representation of the char value to fill the wider format.

                  簡而言之,作為 return 語句表達式的 char 值可通過擴展原語轉換分配給 int 的返回類型.

                  In short, a char value as the expression of a return statement is assignable to a return type of int through widening primitive conversion.

                  這篇關于Java char 也是 int 嗎?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持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替換字符串特定位置的字符?)
                  What is the type of a ternary expression with int and char operands?(具有 int 和 char 操作數的三元表達式的類型是什么?)
                  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 原語?)
                    <legend id='zcDDv'><style id='zcDDv'><dir id='zcDDv'><q id='zcDDv'></q></dir></style></legend>
                      <tbody id='zcDDv'></tbody>
                    • <tfoot id='zcDDv'></tfoot>

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

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

                        • <bdo id='zcDDv'></bdo><ul id='zcDDv'></ul>

                          1. 主站蜘蛛池模板: 工业废水处理|污水处理厂|废水治理设备工程技术公司-苏州瑞美迪 今日娱乐圈——影视剧集_八卦娱乐_明星八卦_最新娱乐八卦新闻 | 电缆隧道在线监测-智慧配电站房-升压站在线监测-江苏久创电气科技有限公司 | 机器视觉检测系统-视觉检测系统-机器视觉系统-ccd检测系统-视觉控制器-视控一体机 -海克易邦 | 上海公司注册-代理记账-招投标审计-上海昆仑扇财税咨询有限公司 上海冠顶工业设备有限公司-隧道炉,烘箱,UV固化机,涂装设备,高温炉,工业机器人生产厂家 | 硫酸钡厂家_高光沉淀硫酸钡价格-河南钡丰化工有限公司 | 二氧化碳/活性炭投加系统,次氯酸钠发生器,紫外线消毒设备|广州新奥 | 节流截止放空阀-不锈钢阀门-气动|电动截止阀-鸿华阀门有限公司 | 华溶溶出仪-Memmert稳定箱-上海协烁仪器科技有限公司 | 氮化镓芯片-碳化硅二极管 - 华燊泰半导体 | 北京百度网站优化|北京网站建设公司-百谷网络科技 | 塑料异型材_PVC异型材_封边条生产厂家_PC灯罩_防撞扶手_医院扶手价格_东莞市怡美塑胶制品有限公司 | 剪刃_纵剪机刀片_分条机刀片-南京雷德机械有限公司 | EPDM密封胶条-EPDM密封垫片-EPDM生产厂家 | 蜂蜜瓶-玻璃瓶-玻璃瓶厂-玻璃瓶生产厂家-徐州贵邦玻璃制品有限公司 | 扒渣机厂家_扒渣机价格_矿用扒渣机_铣挖机_撬毛台车_襄阳永力通扒渣机公司 | 特种电缆厂家-硅橡胶耐高温电缆-耐低温补偿导线-安徽万邦特种电缆有限公司 | 样品瓶(色谱样品瓶)百科-浙江哈迈科技有限公司 | 油漆辅料厂家_阴阳脚线_艺术漆厂家_内外墙涂料施工_乳胶漆专用防霉腻子粉_轻质粉刷石膏-魔法涂涂 | 滚筒线,链板线,总装线,流水线-上海体能机电有限公司 | 真空吸污车_高压清洗车厂家-程力专用汽车股份有限公司官网 | 箱式破碎机_移动方箱式破碎机/价格/厂家_【华盛铭重工】 | 隐形纱窗|防护纱窗|金刚网防盗纱窗|韦柏纱窗|上海青木装潢制品有限公司|纱窗国标起草单位 | TPE塑胶原料-PPA|杜邦pom工程塑料、PPSU|PCTG材料、PC/PBT价格-悦诚塑胶 | 鼓风干燥箱_真空烘箱_高温干燥箱_恒温培养箱-上海笃特科学仪器 | 培训中心-海南香蕉蛋糕加盟店技术翰香原中心官网总部 | 光栅尺_Magnescale探规_磁栅尺_笔式位移传感器_苏州德美达 | 全自动过滤器_反冲洗过滤器_自清洗过滤器_量子除垢环_量子环除垢_量子除垢 - 安士睿(北京)过滤设备有限公司 | 直齿驱动-新型回转驱动和回转支承解决方案提供商-不二传动 | 厦门网站建设_厦门网站设计_小程序开发_网站制作公司【麦格科技】 | 真空泵维修保养,普发,阿尔卡特,荏原,卡西亚玛,莱宝,爱德华干式螺杆真空泵维修-东莞比其尔真空机电设备有限公司 | 山东led显示屏,山东led全彩显示屏,山东LED小间距屏,临沂全彩电子屏-山东亚泰视讯传媒有限公司 | 东亚液氮罐-液氮生物容器-乐山市东亚机电工贸有限公司 | 颚式破碎机,圆锥破碎机,制砂机-新乡市德诚机电制造有限公司 | 长沙广告公司|长沙广告制作设计|长沙led灯箱招牌制作找望城湖南锦蓝广告装饰工程有限公司 | 北京环球北美考试院【官方网站】|北京托福培训班|北京托福培训 | 过滤器_自清洗过滤器_气体过滤器_苏州华凯过滤技术有限公司 | 次氯酸钠厂家,涉水级次氯酸钠,三氯化铁生产厂家-淄博吉灿化工 | 骨灰存放架|骨灰盒寄存架|骨灰架厂家|智慧殡葬|公墓陵园管理系统|网上祭奠|告别厅智能化-厦门慈愿科技 | 桌上式超净工作台-水平送风超净工作台-上海康路仪器设备有限公司 | 手持式线材张力计-套帽式风量罩-深圳市欧亚精密仪器有限公司 | 深圳办公室装修-写字楼装修设计-深圳标榜装饰公司 |