I'm trying to check whether a property is null, but I get a null pointer exception. What's the right way to do this?
private void recursePrintList(myNode head)
{
if(head.next == null) //NullPointerException on this line
{
System.out.println(head.value);
}
else
{
System.out.println(head.value);
recursePrintList(head.next);
}
}