java - Reversing order of recursive output -


i'm making singly-linked queue cs assignment , 1 supposed implement tostring method displays elements such: in -> [ “data 1” , “data 2” , “data 3” ] -> out.

however, first node 1 thats been there latest, method returns oldest element next in , newest out, think reverse order.

here's code:

public string tostring() {         if(value == null){             return "";         }         else if(next == null){             return "\"" + value + "\"";         }         else {             return "\"" + value + "\" ; " + next.tostring();         }     } 

is there way can reverse order?

thanks


Comments

Popular posts from this blog

iphone - Three second countdown in cocos2d -

hyperlink - how to do url routing in php -

c - Avoiding Extra Malloc in Linked List (node->next = NULL) -