Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NullPointerException when trying to add an object to a PriorityQueue

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.

like image 926
meagan Avatar asked Apr 27 '10 04:04

meagan


1 Answers

You haven't initialized the queue.

nodes = new SomePriorityQueue();
like image 144
mkorpela Avatar answered Nov 06 '22 22:11

mkorpela