Java 如何以相反顺序返回所有链表整数的字符串?

Java 如何以相反顺序返回所有链表整数的字符串?,java,string,debugging,linked-list,reverse,Java,String,Debugging,Linked List,Reverse,假设初始curr_节点始终为head。LLNode的实现遵循此代码段的实现。我如何让它工作 private String toString(LLNode<Integer> curr_node) { // TODO if(curr_node==null) { return ""; } else { return curr_node.data+toString(curr_node.link); } }

假设初始curr_节点始终为head。LLNode的实现遵循此代码段的实现。我如何让它工作

private String toString(LLNode<Integer> curr_node) {
    // TODO
    if(curr_node==null)
    {
        return "";
    }
    else
    {
        return curr_node.data+toString(curr_node.link);
    }
}

public class LLNode<T> {
    public T data;
    public LLNode<T> link;
    public LLNode() {
        this(null, null);
    }
    public LLNode(T data, LLNode<T> link) {
        this.data = data;
        this.link = link;
    }
}
私有字符串到字符串(LLNode curr\u node){
//待办事项
if(curr_node==null)
{
返回“”;
}
其他的
{
返回curr\u node.data+toString(curr\u node.link);
}
}
公共类LLNode{
公共数据;
公共节点链路;
公共LLNode(){
这个(空,空);
}
公共LLNode(数据,LLNode链接){
这个数据=数据;
this.link=link;
}
}
请参阅以下内容:

private String toString(LLNode<Integer> curr_node) {
    if(curr_node==null)
    {
        return "";
    }
    else
    {
        return toString(curr_node.link) + "," + curr_node.data; // Your code is the reverse
    }
}

私有字符串到字符串(LLNode curr\u node){
if(curr_node==null)
{
返回“”;
}
其他的
{
返回到字符串(curr\u node.link)+“,“+curr\u node.data;//您的代码是相反的
}
}