Page 2 of 2 FirstFirst 12
Results 21 to 23 of 23
  1. #21
    sehudson's Avatar
    sehudson is offline Senior Member
    Join Date
    Mar 2010
    Posts
    350
    Rep Power
    5

    Default

    ok,

    why isnt lineData[] complaining? I set it to null to initialize it, and then when I wanted to actually put data in it, i just said lineData = myString.split(" "), same thing I'm trying to do with matrixData;

  2. #22
    Junky's Avatar
    Junky is offline Grand Poobah
    Join Date
    Jan 2011
    Location
    Dystopia
    Posts
    3,755
    Rep Power
    7

    Default

    The split method creates an array. You then get lineData to refer (point at) that array. So you are initialising the lineData variable with an array returned from the split method. You do not/have not initialised the matrixData variable. It is null. It does not refer to an array. So you cannot start shoving values into it until you do create the array.

  3. #23
    sehudson's Avatar
    sehudson is offline Senior Member
    Join Date
    Mar 2010
    Posts
    350
    Rep Power
    5

    Default

    gotcha...only problem is I cant say for sure how many lines/integers per line there are in the file immediately in order to say int[][] matrixData = new int[100][100] for example.

Page 2 of 2 FirstFirst 12

Similar Threads

  1. Sum of Integers - From File
    By Cubba27 in forum New To Java
    Replies: 8
    Last Post: 03-25-2010, 11:45 AM
  2. Set of Integers
    By rsjava24 in forum New To Java
    Replies: 7
    Last Post: 01-28-2010, 10:29 AM
  3. Integers and Lists
    By TGH in forum New To Java
    Replies: 8
    Last Post: 01-27-2010, 09:49 AM
  4. Multiples Integers from a String
    By AndrewM16921 in forum New To Java
    Replies: 3
    Last Post: 04-01-2009, 12:00 AM
  5. how to get the Integers out of a String
    By JordashTalon in forum New To Java
    Replies: 10
    Last Post: 01-30-2009, 06:28 PM

Posting Permissions

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