I'm getting a "nullpointerexception" on the following line of code:
does anyone have any ideas? do you need more information?Code:Iterator<createEnemy> el = enemylist.values().iterator();
Printable View
I'm getting a "nullpointerexception" on the following line of code:
does anyone have any ideas? do you need more information?Code:Iterator<createEnemy> el = enemylist.values().iterator();
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:
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();
what I did was - if enemylist != null {} and that worked
Some questions may still be though why was that variable null? And is it OK for it not to be null at that point in your program?