// my print in normal order
public void printList()
{
ListElem curr = head;
while(curr != null)
{
System.out.print(curr.getData() + "->");
curr = curr.getNext();
}
}
// my attempt to print in reverse order
public void printListRev()
{
ListElem curr = head;
if(curr == null) return;
printListRev();
System.out.print(curr.getData() + " ");
}
Since this method doesn't accept any arguments, I'm not sure how to go about doing this recursively. I am trying to figure out how to print out the elements (strings) in a singly linked list.