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

    • <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="qwawimqqmiuu" id='fyq4o'><tfoot id='fyq4o'></tfoot><dl id='fyq4o'><fieldset id='fyq4o'></fieldset></dl></div>

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

      2. 如何將整數(shù)轉(zhuǎn)換為整數(shù)?

        How to convert Integer to int?(如何將整數(shù)轉(zhuǎn)換為整數(shù)?)
          <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="qwawimqqmiuu" id='5NB4L'><tfoot id='5NB4L'></tfoot><dl id='5NB4L'><fieldset id='5NB4L'></fieldset></dl></div>

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

                  問題描述

                  我正在開發(fā)一個 Web 應(yīng)用程序,在該應(yīng)用程序中,數(shù)據(jù)將在客戶端和客戶端之間傳輸.服務(wù)器端.

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

                  我已經(jīng)知道 JavaScript int != Java int.因為,Java int 不能為空,對.現(xiàn)在這是我面臨的問題.

                  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);
                  

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

                  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?

                  任何修復(fù)都會更好.

                  推薦答案

                  正如已經(jīng)在別處寫的:

                  • 對于 Java 1.5 及更高版本,您(幾乎)不需要做任何事情,它由編譯器完成.
                  • 對于 Java 1.4 及之前版本,使用 Integer.intValue() 將 Integer 轉(zhuǎn)換為 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 可以為空,因此在嘗試轉(zhuǎn)換為 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  
                  

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

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

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

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

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

                  相關(guān)文檔推薦

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

                      <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="qwawimqqmiuu" 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>
                            主站蜘蛛池模板: 日日夜精品视频 | 亚洲aⅴ| 男人久久天堂 | 一区二区三区四区在线免费观看 | 国产精品久久久乱弄 | 国产成人99久久亚洲综合精品 | 国产精品不卡一区二区三区 | 亚洲精品久久视频 | 欧美一区免费 | 人人叉 | 亚洲一区二区视频在线观看 | 欧美激情va永久在线播放 | 日韩久久久久久久 | 欧美日本韩国一区二区三区 | 视频二区在线观看 | 91视频免费黄 | 999免费观看视频 | 免费成人高清在线视频 | 欧美视频在线播放 | 成人不卡 | 亚洲不卡在线观看 | av二区三区 | www97影院 | 狠狠做深爱婷婷综合一区 | 北条麻妃av一区二区三区 | 青青草这里只有精品 | 丁香五月网久久综合 | 免费成人毛片 | 国产二区三区 | 久久一区二区av | 一区福利视频 | 国产激情在线播放 | 国产黄色大片 | 国产91久久久久久 | 亚av在线| 蜜桃av鲁一鲁一鲁一鲁 | 午夜影院在线观看 | 成人免费视频网站在线观看 | 国产免费一级片 | 精品欧美一区二区三区久久久 | 波多野结衣二区 |