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.
You haven't initialized the queue.
nodes = new SomePriorityQueue();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With