I am a student so please do not give me the exact answer here, but I need help understanding an error for a programming assignment.
The error says NullPointerException: Cannot read field "left" because "A" is null.
I think that commented out if statement would fix that error but I cannot figure out how to properly implement it.
#Treap null pointer
1 messages · Page 1 of 1 (latest)
<@&987246399047479336> please have a look, thanks.
Nearly. You are right that you need to check for null. However the and (&&) in if (node == null && node.parent == null) is incorrect.
If node is null then the is no object referenced by node and so you can't check if node.parent is null.
In words you want to check "if node is null or node's parent is null"