I have a linked list in which first node contains null object. means firstNode.data is equal to null, firstNode.nextPointer = null, firstNode.previousPointer = null.
And I want to check if firstNode is null or not. So I tried-
if(list.firstNode == null){
//do stuff
}
but this doesn't works?
I also tried equals too. Any suggestions?
I tried printing. And I got as-
{null} -- firstNode
I think your firstNode
is not null
, but its fields are. Try something like this:
if (list.firstNode.data == null) {
//do stuff
}
Did you try
if (list.firstNode.data == null) { /* Do stuff */ }
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