理解しようとしていることがあります。したがって、このメソッドを実行すると、次のようになります。
パブリック文字列 showList()
文字列を返すようにしたいのですが、その後に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.
}