I have a doubleLinkedList and need to implement a recursive toString() method without parameters. Here is what I have, and it throws a NullPointerException
//Print forwards
public String recursiveToString(){
return first.rTS();
}
//Print backwards
public String recursiveBackwardsString(){
return last.rBS();
}
//Recursive helper in the node class
public String rBS(){
if (this!=null)
return info+" "+back.rBS();
return "";
}
//Recursive helper in the node class
public String rTS(){
if (this!=null)
return info+" "+next.rTS();
return "";
}