Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 5 of 5

Thread: Need Help

  1. #1
    Junior Member
    Join Date
    Nov 2010
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Need Help

    EDIT: Fixed it myself. Thanks though.
    Last edited by AmyH; November 23rd, 2010 at 05:59 PM.

  2. #2
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,424
    My Mood
    Hungover
    Thanks
    144
    Thanked 636 Times in 540 Posts

    Default Re: Need Help

    You get the first number with your first call to nextInt(). Then you get the rest of the numbers in a String by calling nextLine(). Then you try to get the numbers again by calling nextInt() in a loop, but you've already gone past them with your nextLine() call, so there is nothing left to scan.

  3. #3
    Junior Member
    Join Date
    Nov 2010
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Need Help

    Quote Originally Posted by KevinWorkman View Post
    You get the first number with your first call to nextInt(). Then you get the rest of the numbers in a String by calling nextLine(). Then you try to get the numbers again by calling nextInt() in a loop, but you've already gone past them with your nextLine() call, so there is nothing left to scan.
    Right. I appreciate your response and I understand what the code is doing, the problem is I can't figure out how to go about printing the list.

  4. #4
    Banned
    Join Date
    May 2010
    Location
    North Central Illinois
    Posts
    1,631
    My Mood
    Sleepy
    Thanks
    390
    Thanked 112 Times in 110 Posts

    Default Re: Need Help

    I don't know what your code is, but wouldn't a for loop probably work.

  5. #5
    Member
    Join Date
    Jul 2010
    Location
    Washington, USA
    Posts
    307
    Thanks
    16
    Thanked 43 Times in 39 Posts

    Default Re: Need Help

    Please don't remove your posts. Keeping your posts can help future users with future problems.