Results 1 to 3 of 3
  1. #1
    Dex is offline Member
    Join Date
    Mar 2012
    Rep Power

    Default Scanner skipping every other line

    close please, fixed myself

    mod edit: this was the original text:

    -Hey can someone please tell me why my scanner sometimes is reading only every other line?

    Java Code:
    Width = scan.nextInt();
    Height = scan.nextInt();
    Info = scan.nextLine();
    for(int row =0; row <2darray.length; row++){
    for(int col =0; col <2darray[row].length; col++){
    2darray[row][col] = null;
    Info = scan.nextLine(); 
    I think it is to do with the nextLine() and my for loop,
    Last edited by JosAH; 08-14-2012 at 09:31 AM. Reason: put back the original text.

  2. #2
    Junky's Avatar
    Junky is offline Grand Poobah
    Join Date
    Jan 2011
    Rep Power

    Default Re: Scanner skipping every other line

    Instead of deleting your post you should leave it and post how you solved it so others with the same problem can see it.

  3. #3
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Voorschoten, the Netherlands
    Blog Entries
    Rep Power

    Default Re: Scanner skipping every other line

    I put back the original text; editing the OP beyond recognition is possible but strongly advised against because it turns a thread useless.

    kind regards,

    Build a wall around Donald Trump; I'll pay for it.

Similar Threads

  1. The Simple, Infamous Line-Skipping ".nextLine()" Method
    By CuppaCoffee in forum New To Java
    Replies: 4
    Last Post: 01-30-2012, 05:04 AM
  2. That old problem with scanner and end of line (enter)
    By Java Riser in forum New To Java
    Replies: 2
    Last Post: 09-29-2011, 01:54 AM
  3. Skipping Scanner
    By chari_autumn in forum New To Java
    Replies: 2
    Last Post: 01-04-2011, 06:29 AM
  4. How to make Scanner read the same line
    By mcollins in forum New To Java
    Replies: 2
    Last Post: 03-03-2009, 06:41 AM
  5. Reading a line from console using Scanner class
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 01-18-2008, 11:52 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts