Results 1 to 5 of 5
  1. #1
    linx2001 is offline Member
    Join Date
    Nov 2012
    Posts
    2
    Rep Power
    0

    Default My code keeps giving me NullPointerException error

    closed, gotta find new method.
    Last edited by linx2001; 11-07-2012 at 02:40 AM.

  2. #2
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    3,965
    Rep Power
    8

    Default Re: My code keeps giving me NullPointerException error

    What line is throwing the NPE? What values are you dereferencing on that line? Which one is null? You can use a debugger or some print statements to figure out what's going on.
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  3. #3
    eRaaaa is offline Senior Member
    Join Date
    Oct 2010
    Location
    Germany
    Posts
    787
    Rep Power
    5

    Default Re: My code keeps giving me NullPointerException error

    Quote Originally Posted by linx2001 View Post
    But I'm using the primitive data type boolean 2D array and it should be automatically initialized to false.
    Not 100%
    You are using the syntax : new boolean[max][];
    2D arrays in java are arrays of arrays! With new boolean[max][] the "unterlaying" arrays are not initialized (nobody knows how big should the array be - no size?!)

  4. #4
    linx2001 is offline Member
    Join Date
    Nov 2012
    Posts
    2
    Rep Power
    0

    Default Re: My code keeps giving me NullPointerException error

    Quote Originally Posted by eRaaaa View Post
    Not 100%
    You are using the syntax : new boolean[max][];
    2D arrays in java are arrays of arrays! With new boolean[max][] the "unterlaying" arrays are not initialized (nobody knows how big should the array be - no size?!)
    The problem is if I initialize the second part, then it will return heap memory space error since the number of inputs from the file I have to read in is extremely large. So I have to dynamically work at it. P.S. thanks for the response, that helped me understand better.

  5. #5
    quad64bit's Avatar
    quad64bit is offline Moderator
    Join Date
    Jul 2009
    Location
    VA
    Posts
    1,323
    Rep Power
    7

    Default Re: My code keeps giving me NullPointerException error

    closed, gotta find new method.
    Please don't delete your posts like this. Leave them up for others!

Similar Threads

  1. Replies: 5
    Last Post: 06-25-2012, 12:02 PM
  2. Real simple code giving me trouble!
    By dre in forum New To Java
    Replies: 1
    Last Post: 09-24-2011, 05:13 PM
  3. Replies: 10
    Last Post: 07-20-2011, 02:11 PM
  4. Java code giving error
    By alfarida in forum New To Java
    Replies: 3
    Last Post: 11-10-2010, 07:11 PM
  5. Pls check why my code is giving a runtime error
    By Beginner in forum New To Java
    Replies: 3
    Last Post: 05-26-2010, 12:32 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
  •