Results 1 to 4 of 4
  1. #1
    natdizzle's Avatar
    natdizzle is offline Nathan Nelson
    Join Date
    Jan 2009
    Posts
    105
    Rep Power
    0

    Default nullpointerexception

    I'm getting a "nullpointerexception" on the following line of code:

    Java Code:
    Iterator<createEnemy> el = enemylist.values().iterator();
    does anyone have any ideas? do you need more information?

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default Re: nullpointerexception

    You look to have enough information to solve this yourself. Either enemylist or the return from its values() method is null. Test for this just above this line, and then trace back in your code to see why its null.

    By test, I've done something like:

    Java Code:
    System.out.println("is enemylist null?: " + (enemylist == null));
    System.out.println("is enemylist.values() null?: " + (enemylist.values() == null));
    
    // original line:
    Iterator<createEnemy> el = enemylist.values().iterator();

  3. #3
    natdizzle's Avatar
    natdizzle is offline Nathan Nelson
    Join Date
    Jan 2009
    Posts
    105
    Rep Power
    0

    Default Re: nullpointerexception

    what I did was - if enemylist != null {} and that worked

  4. #4
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

Similar Threads

  1. NullPointerException
    By maxspyderweb in forum New To Java
    Replies: 5
    Last Post: 03-02-2011, 11:42 AM
  2. NullPointerException
    By s0meb0dy in forum New To Java
    Replies: 3
    Last Post: 10-09-2010, 09:12 PM
  3. NullPointerException
    By Juuno in forum New To Java
    Replies: 1
    Last Post: 02-11-2010, 06:43 PM
  4. NullPointerException help me!
    By phancuong87 in forum New To Java
    Replies: 4
    Last Post: 01-19-2010, 05:01 PM
  5. NullPointerException
    By Aika in forum New To Java
    Replies: 8
    Last Post: 11-19-2008, 12:34 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
  •