これは、別のクラスに実装する必要があるインターフェイスのメソッドであり、作成方法がわかりません。printStream 引数を指定して linkedList を使用してスタックを出力する必要があります。クラス Node(forlinkedList) 内に、メソッド getObject() があります。
import java.io.PrintStream;
import java.util.NoSuchElementException;
public interface StringStack {
public boolean isEmpty();
public void push(String item);
public String pop() throws NoSuchElementException;
public String peek() throws NoSuchElementException;
/**
* print the contents of the stack, starting from the item
* on the top,
* to the stream given as argument. For example,
* to print to the standard output you need to pass System.out as
* an argument. E.g.,
* printStack(System.out);
*/
public void printStack(PrintStream stream);
public int size();
}
public class StringStackImpl implements StringStack {
private Node head;
....
public void printStack(PrintStream stream) {???}
}