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

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

  1. <tfoot id='lx2Ts'></tfoot>

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

      <legend id='lx2Ts'><style id='lx2Ts'><dir id='lx2Ts'><q id='lx2Ts'></q></dir></style></legend>

      使用 nextInt 和 nextLine() 時遇到問題

      Trouble using nextInt and nextLine()(使用 nextInt 和 nextLine() 時遇到問題)

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

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

              <tbody id='s2RLd'></tbody>

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

              <tfoot id='s2RLd'></tfoot>
            • <legend id='s2RLd'><style id='s2RLd'><dir id='s2RLd'><q id='s2RLd'></q></dir></style></legend>
                本文介紹了使用 nextInt 和 nextLine() 時遇到問題的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                問題描述

                這不是讓我輸入我的名字,但它確實可以正常工作.我知道我可以更改語句的順序,但還有其他方法可以做到嗎?

                It's not letting me put my name in but it does the age works fine. I know i can change the order of the statements but is there another way I could do it?

                import java.util.Scanner;
                
                public class ScannerErr2
                {
                  public static void main(String [] args)
                  {
                    Scanner keyboard= new Scanner(System.in);
                    String name;
                    int    age;
                
                    System.out.print("Enter your age : ");
                    age= keyboard.nextInt();
                    System.out.print("Enter your name: ");
                    name= keyboard.nextLine();
                
                    System.out.println("Age : "+age);
                    System.out.println("Name: "+name);
                  }
                }
                

                推薦答案

                你的問題是下一個 int 沒有考慮你名字部分的輸入中的換行符.因此名稱返回為空白.

                You problem is that the next int doesn't consider the new line character which goes in the input for your name part. Hence name is returned as blank.

                您可以通過 2 種方式更改代碼:

                You can change your code in 2 ways:

                System.out.print("Enter your age : ");
                age = keyboard.nextInt();
                keyboard.nextLine();
                System.out.print("Enter your name: ");
                name = keyboard.nextLine();
                

                System.out.print("Enter your age : ");
                age = Integer.parseInt(keyboard.nextLine().trim());
                System.out.print("Enter your name: ");
                name = keyboard.nextLine();
                

                我個人喜歡第二種方式.

                I personally like the second way.

                這篇關于使用 nextInt 和 nextLine() 時遇到問題的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

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

                相關文檔推薦

                How can I detect integer overflow on 32 bits int?(如何檢測 32 位 int 上的整數溢出?)
                Local variables before return statements, does it matter?(return 語句之前的局部變量,這有關系嗎?)
                How to convert Integer to int?(如何將整數轉換為整數?)
                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?)
              1. <i id='2etux'><tr id='2etux'><dt id='2etux'><q id='2etux'><span id='2etux'><b id='2etux'><form id='2etux'><ins id='2etux'></ins><ul id='2etux'></ul><sub id='2etux'></sub></form><legend id='2etux'></legend><bdo id='2etux'><pre id='2etux'><center id='2etux'></center></pre></bdo></b><th id='2etux'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='2etux'><tfoot id='2etux'></tfoot><dl id='2etux'><fieldset id='2etux'></fieldset></dl></div>
                  <bdo id='2etux'></bdo><ul id='2etux'></ul>
                  <tfoot id='2etux'></tfoot>

                • <legend id='2etux'><style id='2etux'><dir id='2etux'><q id='2etux'></q></dir></style></legend>

                          <tbody id='2etux'></tbody>

                        <small id='2etux'></small><noframes id='2etux'>

                        • 主站蜘蛛池模板: 亚洲精品综合 | av中文在线播放 | 青青草原综合久久大伊人精品 | 国户精品久久久久久久久久久不卡 | 久久亚洲天堂 | 91精品久久久久久久久久小网站 | 91成人小视频 | 天天天操操操 | 91在线视频观看免费 | 91精品国产91久久久久久最新 | 亚洲精品日本 | 精品国产乱码久久久久久中文 | 国产91在线播放 | 亚洲精品福利视频 | 97国产精品| 亚洲综合色视频在线观看 | 亚洲视频观看 | 成人免费视频网站在线看 | 国产污视频在线 | 永久看片| 成年人网站在线观看视频 | 欧美日韩一区二区三区四区 | www国产成人免费观看视频,深夜成人网 | 黑人精品 | www.亚洲区 | 91亚洲国产成人久久精品网站 | 91精品国产乱码久久久久久久 | 99这里只有精品视频 | 国产传媒 | 午夜理伦三级理论三级在线观看 | 羞羞视频网站免费看 | 黄色一级大片在线免费看产 | 久久久高清 | 四虎影院在线观看av | 亚洲免费视频播放 | 美女在线观看国产 | 91综合网 | 亚洲精品久| 国产乱码精品一区二三赶尸艳谈 | 99国内精品久久久久久久 | 亚洲在线一区 |