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

    • <bdo id='fyq4o'></bdo><ul id='fyq4o'></ul>
    1. <tfoot id='fyq4o'></tfoot><legend id='fyq4o'><style id='fyq4o'><dir id='fyq4o'><q id='fyq4o'></q></dir></style></legend>
      <i id='fyq4o'><tr id='fyq4o'><dt id='fyq4o'><q id='fyq4o'><span id='fyq4o'><b id='fyq4o'><form id='fyq4o'><ins id='fyq4o'></ins><ul id='fyq4o'></ul><sub id='fyq4o'></sub></form><legend id='fyq4o'></legend><bdo id='fyq4o'><pre id='fyq4o'><center id='fyq4o'></center></pre></bdo></b><th id='fyq4o'></th></span></q></dt></tr></i><div class="8njwc7m" id='fyq4o'><tfoot id='fyq4o'></tfoot><dl id='fyq4o'><fieldset id='fyq4o'></fieldset></dl></div>

      1. <small id='fyq4o'></small><noframes id='fyq4o'>

      2. 如何將整數轉換為整數?

        How to convert Integer to int?(如何將整數轉換為整數?)
          <tbody id='5NB4L'></tbody>
        <legend id='5NB4L'><style id='5NB4L'><dir id='5NB4L'><q id='5NB4L'></q></dir></style></legend>
        • <bdo id='5NB4L'></bdo><ul id='5NB4L'></ul>

          <tfoot id='5NB4L'></tfoot>

            <small id='5NB4L'></small><noframes id='5NB4L'>

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

                  本文介紹了如何將整數轉換為整數?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  我正在開發一個 Web 應用程序,在該應用程序中,數據將在客戶端和客戶端之間傳輸.服務器端.

                  I am working on a web application in which data will be transfer between client & server side.

                  我已經知道 JavaScript int != Java int.因為,Java int 不能為空,對.現在這是我面臨的問題.

                  I already know that JavaScript int != Java int. Because, Java int cannot be null, right. Now this is the problem I am facing.

                  我將我的 Java int 變量更改為 Integer.

                  I changed my Java int variables into Integer.

                  public void aouEmployee(Employee employee) throws SQLException, ClassNotFoundException
                  {
                     Integer tempID = employee.getId();
                     String tname = employee.getName();
                     Integer tage = employee.getAge();
                     String tdept = employee.getDept();
                     PreparedStatement pstmt;
                     Class.forName("com.mysql.jdbc.Driver");
                     String url ="jdbc:mysql://localhost:3306/general";
                     java.sql.Connection con = DriverManager.getConnection(url,"root", "1234");
                     System.out.println("URL: " + url);
                     System.out.println("Connection: " + con);
                     pstmt = (PreparedStatement) con.prepareStatement("REPLACE INTO PERSON SET ID=?, NAME=?, AGE=?, DEPT=?");
                     pstmt.setInt(1, tempID);
                     pstmt.setString(2, tname);
                     pstmt.setInt(3, tage);
                     pstmt.setString(4, tdept);
                     pstmt.executeUpdate();
                   }
                  

                  我的問題在這里:

                  pstmt.setInt(1, tempID);
                  
                  pstmt.setInt(3, tage);
                  

                  我不能在這里使用整數變量.我試過 intgerObject.intValue();但它使事情變得更加復雜.我們還有其他轉換方法或轉換技術嗎?

                  I cant use the Integer variables here. I tried with intgerObject.intValue(); But it makes things more complex. Do we have any other conversion methods or conversion techniques?

                  任何修復都會更好.

                  推薦答案

                  正如已經在別處寫的:

                  • 對于 Java 1.5 及更高版本,您(幾乎)不需要做任何事情,它由編譯器完成.
                  • 對于 Java 1.4 及之前版本,使用 Integer.intValue() 將 Integer 轉換為 int.
                  • For Java 1.5 and later you don't need to do (almost) anything, it's done by the compiler.
                  • For Java 1.4 and before, use Integer.intValue() to convert from Integer to int.

                  但是正如您所寫,Integer 可以為空,因此在嘗試轉換為 int 之前檢查一下是明智的(否則可能會遇到 NullPointerException).

                  BUT as you wrote, an Integer can be null, so it's wise to check that before trying to convert to int (or risk getting a NullPointerException).

                  pstmt.setInt(1, (tempID != null ? tempID : 0));  // Java 1.5 or later
                  

                  pstmt.setInt(1, (tempID != null ? tempID.intValue() : 0));  // any version, no autoboxing  
                  

                  * 使用默認值零,也可以什么都不做,顯示警告或...

                  我大多不喜歡使用自動裝箱(第二個示例行),所以很清楚我想要做什么.

                  I mostly prefer not using autoboxing (second sample line) so it's clear what I want to do.

                  這篇關于如何將整數轉換為整數?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

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

                  相關文檔推薦

                  How can I detect integer overflow on 32 bits int?(如何檢測 32 位 int 上的整數溢出?)
                  Local variables before return statements, does it matter?(return 語句之前的局部變量,這有關系嗎?)
                  How do I create an int array with randomly shuffled numbers in a given range(如何在給定范圍內創建一個隨機打亂數字的 int 數組)
                  Inconsistent behavior on java#39;s ==(java的行為不一致==)
                  Why is Java able to store 0xff000000 as an int?(為什么 Java 能夠將 0xff000000 存儲為 int?)
                  Unexpected result in long/int division(意外結果導致長/整數除法)

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

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

                        <tfoot id='mfBoV'></tfoot>

                            <tbody id='mfBoV'></tbody>

                          1. <legend id='mfBoV'><style id='mfBoV'><dir id='mfBoV'><q id='mfBoV'></q></dir></style></legend>
                            主站蜘蛛池模板: CPSE安博会 | 哲力实业_专注汽车涂料汽车漆研发生产_汽车漆|修补油漆品牌厂家 长沙一级消防工程公司_智能化弱电_机电安装_亮化工程专业施工承包_湖南公共安全工程有限公司 | 浩方智通 - 防关联浏览器 - 跨境电商浏览器 - 云雀浏览器 | 北京签证代办_签证办理_商务签证_旅游签证_寰球签证网 | 机制砂选粉机_砂石选粉机厂家-盐城市助成粉磨科技有限公司 | 煤粉取样器-射油器-便携式等速飞灰取样器-连灵动 | 洁净化验室净化工程_成都实验室装修设计施工_四川华锐净化公司 | 并网柜,汇流箱,电控设备,中高低压开关柜,电气电力成套设备,PLC控制设备订制厂家,江苏昌伟业新能源科技有限公司 | 北京康百特科技有限公司-分子蒸馏-短程分子蒸馏设备-实验室分子蒸馏设备 | 避光流动池-带盖荧光比色皿-生化流动比色皿-宜兴市晶科光学仪器 东莞爱加真空科技有限公司-进口真空镀膜机|真空镀膜设备|Polycold维修厂家 | 硫酸亚铁-聚合硫酸铁-除氟除磷剂-复合碳源-污水处理药剂厂家—长隆科技 | 天津货架厂_穿梭车货架_重型仓储货架_阁楼货架定制-天津钢力仓储货架生产厂家_天津钢力智能仓储装备 | 煤矿支护网片_矿用勾花菱形网_缝管式_管缝式锚杆-邯郸市永年区志涛工矿配件有限公司 | 玉米加工设备,玉米深加工机械,玉米糁加工设备.玉米脱皮制糁机 华豫万通粮机 | 集菌仪_智能集菌仪_全封闭集菌仪_无菌检查集菌仪厂家-那艾 | 成都办公室装修-办公室设计-写字楼装修设计-厂房装修-四川和信建筑装饰工程有限公司 | 远程会诊系统-手术示教系统【林之硕】医院远程医疗平台 | 威廉希尔WilliamHill·足球(中国)体育官方网站 | 茶楼装修设计_茶馆室内设计效果图_云臻轩茶楼装饰公司 | 东莞工作服_东莞工作服定制_工衣订做_东莞厂服 | 送料机_高速冲床送料机_NC伺服滚轮送料机厂家-东莞市久谐自动化设备有限公司 | 一体式钢筋扫描仪-楼板测厚仪-裂缝检测仪-泰仕特(北京) | 农业四情_农业气象站_田间小型气象站_智慧农业气象站-山东风途物联网 | 刹车盘机床-刹车盘生产线-龙口亨嘉智能装备| 光照全温振荡器(智能型)-恒隆仪器| 附着力促进剂-尼龙处理剂-PP处理剂-金属附着力处理剂-东莞市炅盛塑胶科技有限公司 | 不干胶标签,不干胶标签纸_厂家-山东同力胶粘制品 | 武汉高低温试验箱_恒温恒湿试验箱厂家-武汉蓝锐环境科技有限公司 | 卫生纸复卷机|抽纸机|卫生纸加工设备|做卫生纸机器|小型卫生纸加工需要什么设备|卫生纸机器设备多少钱一台|许昌恒源纸品机械有限公司 | 浙江皓格药业有限公司| 反渗透阻垢剂-缓蚀阻垢剂厂家-循环水处理药剂-山东鲁东环保科技有限公司 | 河南正规膏药生产厂家-膏药贴牌-膏药代加工-修康药业集团官网 | 座椅式升降机_无障碍升降平台_残疾人升降平台-南京明顺机械设备有限公司 | 东莞压铸厂_精密压铸_锌合金压铸_铝合金压铸_压铸件加工_东莞祥宇金属制品 | 上海办公室装修,写字楼装修—启鸣装饰设计工程有限公司 | 不锈钢复合板|钛复合板|金属复合板|南钢集团安徽金元素复合材料有限公司-官网 | 青岛侦探_青岛侦探事务所_青岛劝退小三_青岛婚外情取证-青岛王军侦探事务所 | 废气处理_废气处理设备_工业废气处理_江苏龙泰环保设备制造有限公司 | 外观设计_设备外观设计_外观设计公司_产品外观设计_机械设备外观设计_东莞工业设计公司-意品深蓝 | 青岛代理记账_青岛李沧代理记账公司_青岛崂山代理记账一个月多少钱_青岛德辉财税事务所官网 | 昆明网络公司|云南网络公司|昆明网站建设公司|昆明网页设计|云南网站制作|新媒体运营公司|APP开发|小程序研发|尽在昆明奥远科技有限公司 |