NullPointerException when trying to add an object to a PriorityQueue
- by meagan
i keep getting a null pointer exception when trying to add an object to a priority queue
i initialize the queue:
private PriorityQueue<NodeObject> nodes;
and here i try to add to it:
NodeObject childNode = new NodeObject(child, 1);
nodes.add(childNode);
why doesn't this work? i know my NodeObject is not null because i create it right before i add it.