Comments

  1. Weeber:

    Dude, in the name of the self-taught Java community I want to thank you for this :) this have been bugging me since I started practicing with user input.

    December 29, 2008 at 12:15 pm |
  2. Ali:

    Thanks so much! I have to turn in an assignment tomorrow, and this helped me solve the issue!! YOU ARE THE BEST!!!

    January 15, 2009 at 6:55 pm |
  3. Corri:

    Thanks! I hadn’t written Java for over a year and a half, and then had to write for a simple assignment, and couldn’t remember this little quip. Thanks for posting it!

    January 31, 2009 at 2:06 am |
  4. Shugi:

    Thanks for the help! This has been bugging me and my class, now we have a solution!

    February 20, 2009 at 6:51 pm |
  5. Sam:

    Thanks so much!!! greatly appreciate this, i have program due this monday and been so annoyed as the line being skipped, but this saved me! thanks mate

    March 27, 2009 at 8:19 pm |
  6. Vincent:

    Yep this is the first java unit I’ve done in 2 years and I’ve forgotten how to get around the issue, thanks for the reminder m8 =)

    April 1, 2009 at 1:30 am |
  7. Joel:

    You are my hero, dude! I’ve been so frustrated over this stupid problem and you solved it! YAYYY!!

    April 23, 2009 at 4:52 pm |
  8. Anthony:

    So helpful. I’ve been trying to debug this issue for an hour and I was pulling my hair out. Great article.

    May 12, 2009 at 9:06 pm |
  9. Noxx:

    Thanks for the solution! Been bugging me for a while. :)

    September 15, 2009 at 1:08 pm |
  10. IC:

    Fantastic – thanks for this great article.

    November 11, 2009 at 1:08 am |
  11. Deco:

    I’ve been stuck on this for ages!

    Thank you!

    November 7, 2010 at 9:18 pm |
  12. Ian:

    Just like everyone else is saying: As a member of the self-taught java community, I can not thank you enough. I had been trying to debug this issue for ages. Thank you!

    February 9, 2011 at 10:09 pm |
  13. Paul:

    You are a life saver bro.

    February 16, 2011 at 6:13 pm |
  14. Yani:

    Your explanation just saved me some more hours of frustration. I was going crazy not understanding why it kept throwing an exception in my code. Thank you times a million!

    April 24, 2011 at 10:11 pm |
  15. MikeQuioda:

    Men you really saved my fu**n ass! I had been stuck in this issue for hours, and I was about to give up…. but now…. I just have to TAHNK YOU!!! really … thanks a lot! (:

    June 2, 2011 at 6:02 pm |
  16. sam:

    just the help i needed. thank you!

    July 24, 2011 at 4:08 am |
  17. Martin:

    Almost 3 years on and this page is still helping people.

    You sir, are a genius!

    September 23, 2011 at 7:16 am |
  18. Steven:

    Dude, this was a major help to me — this was driving me absolutely insane. Great work! Thanks again!!

    October 3, 2011 at 10:27 am |
  19. Mohan:

    This is awesome, i had looked up so many webpages, none had a solution as simple as this … Thanks a bunch.

    October 21, 2011 at 1:22 pm |
  20. cody:

    and four years after I’ve been using java things like this still get me.

    thanks man.

    also something else that worked for me was to just use next() instead – you lose capability of having spaces in your inputs though

    October 30, 2011 at 9:22 pm |
  21. Reza:

    Hello Ryan and thanks for the solution.
    But when I use this solution for 2 string input, Only second string will be printed and another one will be ignored and skipped.

    check the following code:
    CustomerId[i] = s.nextInt();
    System.out.println(“Enter First Name: “);
    Fname[i] = s.nextLine();
    s.nextLine();
    System.out.println(“Enter Last Name: “);
    Lname[i] = s.nextLine();

    //Printing the above inputs:
    System.out.println (“Name: ” + Fname + Lname);
    //Only Lname will be printed and Fname will be skipped.

    Please help me to fix the issue. I have to deliver this assignment to my prof tomorrow.

    December 30, 2011 at 4:34 am |
  22. Reza:

    Great!
    I fixed it out.
    Thanks man

    Happy new year :)

    January 1, 2012 at 5:19 pm |
  23. Archee:

    I literally spent over 3 hours trying to figure out this problem myself. I eventually gave up and googled the problem (which I should have done after the first 10 minutes of trying) and I found this solution. Thank you so much!

    February 2, 2012 at 4:11 pm |
  24. Rick:

    God Bless you, sir! You are a gentleman and a scholar!

    This has been driving me up a wall. Now maybe I can finish my project in the two hours I have left.

    February 26, 2012 at 9:52 pm |
  25. UMI:

    Thank you based Ryan.

    March 13, 2012 at 9:28 pm |
  26. thanks a lot bro!

    May 24, 2012 at 7:41 am |
  27. [...] Here is an article about why this issue occurs: Stop Input Skipping in Java | Ryan Rampersad Apparently it happens whenever nextInt() is followed by nextLine(). The article above suggests a [...]

    August 4, 2012 at 12:02 pm |

Leave a Reply

You must be logged in to post a comment.