Search:

Type: Posts; User: Norm

Search: Search took 0.11 seconds.

  1. Re: Im having trouble storing ints that have been converted at the end of a line in a file into a 2d array.

    What variable is null?
    testMarks or scanner2
  2. Re: Im having trouble storing ints that have been converted at the end of a line in a file into a 2d array.

    Use the Scanner class's useDelimiter() method. There was one in the earlier posted code.
  3. Re: Im having trouble storing ints that have been converted at the end of a line in a file into a 2d array.

    Here's a start on the design:
    init file for scanning
    begin loop to read lines from file
    read a line from file and print it for debug
    1). read in all the ints on the lines in the file and store...
  4. Re: Im having trouble storing ints that have been converted at the end of a line in a file into a 2d array.

    The code needs to be redone. You need a new design and new code.
  5. Re: Im having trouble storing ints that have been converted at the end of a line in a file into a 2d array.

    Start by designing what the method should do. Make a list of the steps(simple steps) that the code needs to do.
    When you get a good design, then try coding it in small steps, with testing of each...
  6. Re: Im having trouble storing ints that have been converted at the end of a line in a file into a 2d array.

    Please explain what the problems are.

    The current code does not do what you want. It needs to be rewritten to do the things you want:
    1). read in all the ints on the lines in the file and...
  7. Re: Im having trouble storing ints that have been converted at the end of a line in a file into a 2d array.

    Do you have code for the new program? The old code doesn't do what you want.

    The new program needs a second array to hold the Strings
  8. Re: Im having trouble storing ints that have been converted at the end of a line in a file into a 2d array.

    Does this mean you are starting over with the program?
    What are the steps the new program needs to take to
    read in the first part of the lines and save the numbers in one array
    and then read the...
  9. Re: Im having trouble storing ints that have been converted at the end of a line in a file into a 2d array.

    Sorry, I don't know what the "other two" are. Can you post the current code with comments that shows the problem?
  10. Re: Im having trouble storing ints that have been converted at the end of a line in a file into a 2d array.

    Use the scanner variable to call the useDelimiter() method:

    scanner2.useDelimiter("[ ]*(,)[ ]*");

    This was a problem I talked about in the other thread: The code chained together too many...
  11. Re: Im having trouble storing ints that have been converted at the end of a line in a file into a 2d array.

    what does "still null" mean? If there are error messages, copy the full text and print them.

    Change
    testMarks[add][columns + num] = scanner.nextInt();
    to

    String aStr2 =...
  12. Re: Im having trouble storing ints that have been converted at the end of a line in a file into a 2d array.

    String aStr = scanner.nextLine(); // read next line into a variable
    System.out.println("aStr="+aStr); // show what was read
    Scanner scanner2 = new Scanner(aStr); // set the Scanner to use...
  13. Re: Im having trouble storing ints that have been converted at the end of a line in a file into a 2d array.

    That part of the code is not changed. The change is removing the calls to Scanner methods to a separate line,
    printing what was read and then the value read is used where the calls to the Scanner...
  14. Re: Im having trouble storing ints that have been converted at the end of a line in a file into a 2d array.

    Ok, now you need to change the code some so that ALL data that is read in is printed before it is used. These statements need to be changed:

    Scanner scanner2 = new...
  15. Re: Im having trouble storing ints that have been converted at the end of a line in a file into a 2d array.

    I guess asking for two things at the same time was confusing. Let me ask for them one at a time:

    Post the full code with the debug println statements.
  16. Re: Im having trouble storing ints that have been converted at the end of a line in a file into a 2d array.

    If you want help with your problem, this is what you have to do:

    Post the code with the debug println statements.

    Post the output from the program. Not an image.
  17. Re: Im having trouble storing ints that have been converted at the end of a line in a file into a 2d array.

    Post the code with the debug println statements.

    Post the output from the program.
  18. Re: Im having trouble storing ints that have been converted at the end of a line in a file into a 2d array.

    Where did you post the version of the code with the println() statements for debugging?

    Where did you post the output for when the code with the debug printlns was executed?
  19. Re: Im having trouble storing ints that have been converted at the end of a line in a file into a 2d array.

    Post the code with the println statements that I've suggested be added for debugging.

    Also post the output from when you have executed the code with those printlns.

    You need to learn how to...
  20. Re: Im having trouble storing ints that have been converted at the end of a line in a file into a 2d array.

    Have you tried debugging the code as suggested in post#20 in that thread?
    You need to add the println statements so you can see what the computer sees when it executes the code.

    If you get...
  21. Re: Im having trouble storing ints that have been converted at the end of a line in a file into a 2d array.

    Please edit your post and wrap your code with


    <YOUR CODE HERE>

    to get highlighting and preserve formatting.


    Please copy and paste here the full text of the error messages.
Results 1 to 21 of 21