久久久久久久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() 時(shí)遇到問(wèn)題

      Trouble using nextInt and nextLine()(使用 nextInt 和 nextLine() 時(shí)遇到問(wèn)題)

        • <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() 時(shí)遇到問(wèn)題的處理方法,對(duì)大家解決問(wèn)題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)吧!

                問(wèn)題描述

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

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

                推薦答案

                你的問(wèn)題是下一個(gè) int 沒(méi)有考慮你名字部分的輸入中的換行符.因此名稱返回為空白.

                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.

                您可以通過(guò) 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();
                

                我個(gè)人喜歡第二種方式.

                I personally like the second way.

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

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

                相關(guān)文檔推薦

                How can I detect integer overflow on 32 bits int?(如何檢測(cè) 32 位 int 上的整數(shù)溢出?)
                Local variables before return statements, does it matter?(return 語(yǔ)句之前的局部變量,這有關(guān)系嗎?)
                How to convert Integer to int?(如何將整數(shù)轉(zhuǎn)換為整數(shù)?)
                How do I create an int array with randomly shuffled numbers in a given range(如何在給定范圍內(nèi)創(chuàng)建一個(gè)隨機(jī)打亂數(shù)字的 int 數(shù)組)
                Inconsistent behavior on java#39;s ==(java的行為不一致==)
                Why is Java able to store 0xff000000 as an int?(為什么 Java 能夠?qū)?0xff000000 存儲(chǔ)為 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| 精品国产欧美一区二区三区成人 | 国产一区二区三区在线 | 欧美在线亚洲 | 久久久在线视频 | 久久av一区 | 秋霞影院一区二区 | 国产精品久久久久久妇女 | 国产精品成人一区二区三区夜夜夜 | 超黄毛片| 91av视频在线观看 | 精精精精xxxx免费视频 | 日韩成人免费中文字幕 | 欧美人成在线视频 | 色婷婷一区二区三区四区 | 亚洲精品视频观看 | 日本三级全黄三级三级三级口周 | 在线视频日韩 | 精品久久久久久久久久久久久久 | 在线视频日韩精品 | 久久国产一区二区 | 中文字幕亚洲精品 | 操久久| 成人影院网站ww555久久精品 | 中文二区| 欧美一级高潮片免费的 | 一级做a爰片久久毛片免费看 | 噜久寡妇噜噜久久寡妇 | 亚洲成人免费观看 | 中文字幕国产视频 | 欧美大片一区 | 成人在线小视频 | 欧美日日日日bbbbb视频 | 久久久av中文字幕 | 午夜视频在线观看一区二区 | 国产精品视频网 | 91精品国产91久久久久久最新 | 中文字幕视频在线观看 | 亚洲视频在线播放 |