public class LinkedStack
private static class Elem
private T value;
private Elem
private Elem(T value, Elem
this.value = value;
this.next = next;
}
}
private Elem
public boolean isEmpty() {
return top == null;
}
public void push(E value) {
top = new Elem
}
public E peek() {
return top.value;
}
public E pop() {
E saved = top.value;
top = top.next;
return saved;
}
}