我有一些我想弄清楚的事情。所以当我运行这个方法时,调用:
公共字符串显示列表()
我希望它返回字符串,但之后调用了一个名为 displayMenu 的方法,因此在调用 showList 时它会自动转到下一个方法。这可能吗?
showList 方法:(我想调用另一个名为 public void displayMenu() 的方法)
public String showList()
{
sortList();
int i = 0;
String retStr = "The nodes in the list are:\n";
LinkedListNode current = front;
while(current != null){
i++;
retStr += "Node " + i + " is: " + current.getData() + "\n";
current = current.getNext();
}
return retStr;
//Would like to call the displayMenu() here, but I can't after the string returns it is unreachable.
}