Results 1 to 7 of 7
  1. #1
    LoViNgHeArTy is offline Member
    Join Date
    Apr 2011
    Posts
    10
    Rep Power
    0

    Default NullPointerException help!

    xxxxxxxxxx
    Last edited by LoViNgHeArTy; 05-18-2011 at 08:52 PM.

  2. #2
    Dark's Avatar
    Dark is offline Senior Member
    Join Date
    Apr 2011
    Location
    Camp Lejuene, North Carolina
    Posts
    643
    Rep Power
    4

    Default

    Can you post your error log? Theres nothing wrong with getting help with your code, if you don't understand something then you don't understand something and you need help.

    If you post your error log we will be able to narrow down your problem. It will give you a line where you are getting the nullpointerexception and that will give us a huge clue as to why your code is having problems.
    • Use [code][/code] tags when posting code. That way people don't want to stab their eyes out when trying to help you.
    • +Rep people for helpful posts.

  3. #3
    kjkrum's Avatar
    kjkrum is offline Senior Member
    Join Date
    Apr 2011
    Location
    Tucson, AZ
    Posts
    1,060
    Rep Power
    6

    Default

    Please only put your Java code inside the code tags. I'm finding it rather difficult to tell what's supposed to be code and what's supposed to be your descriptions of it.

    Following the standard naming conventions would also help.

  4. #4
    LoViNgHeArTy is offline Member
    Join Date
    Apr 2011
    Posts
    10
    Rep Power
    0

    Default

    xxxxxxxxxx
    Last edited by LoViNgHeArTy; 05-18-2011 at 08:52 PM.

  5. #5
    sunde887's Avatar
    sunde887 is offline Moderator
    Join Date
    Jan 2011
    Location
    Richmond, Virginia
    Posts
    3,069
    Blog Entries
    3
    Rep Power
    8

    Default

    There is a lot of missing information in this code, for example, where is the manipulates class? Where is the arrayofobjects.rangomgenerator method? In the method you are showing what is gen1 and gen2?

    When do you fill the static array? It's instantiated at the top but I don't see you filling it. Also, as stated above, follow standard naming conventions and post up the stack trace(error message) exactly(copy/paste it in code tags).



    Edit: saw new post, try printing the game array and see what is produced.
    Last edited by sunde887; 05-18-2011 at 10:19 AM.

  6. #6
    kjkrum's Avatar
    kjkrum is offline Senior Member
    Join Date
    Apr 2011
    Location
    Tucson, AZ
    Posts
    1,060
    Rep Power
    6

    Default

    Sunde's right -- you need to fill your array. In your GameBoard class you have:

    Java Code:
    static Cell[] game= new Cell[100];
    You need to initialize each element of that array, like so:

    Java Code:
    for(int i = 0; i < game.length; ++i)
         game[i] = new Cell(pos, des, type);
    Get in the habit of using standard Java naming conventions!

  7. #7
    LoViNgHeArTy is offline Member
    Join Date
    Apr 2011
    Posts
    10
    Rep Power
    0

    Default

    Thanks guys problem solved. no more exceptions. Thanks You.:D

Similar Threads

  1. NullPointerException
    By donchini in forum New To Java
    Replies: 4
    Last Post: 05-20-2010, 02:11 AM
  2. NullPointerException help me!
    By phancuong87 in forum New To Java
    Replies: 4
    Last Post: 01-19-2010, 05:01 PM
  3. NullPointerException: I can't get rid of it.
    By mcashe in forum AWT / Swing
    Replies: 2
    Last Post: 08-17-2009, 10:16 PM
  4. NullPointerException
    By mjz in forum JDBC
    Replies: 1
    Last Post: 08-06-2009, 12:46 PM
  5. NullPointerException
    By adeeb in forum AWT / Swing
    Replies: 3
    Last Post: 06-11-2008, 09:42 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
  •