public class Stack { private Node first; public Stack(){ this.first = null; } public boolean isEmpty(){ return this.first == null; } public void push(T val){ Node added = new Node(val); added.next = this.first; this.first = added; } public T pop (){ if (this.first == null) return null; T ret = this.first.wert; this.first = this.first.next; return ret; } public T top (){ if (this.first == null) return null; return this.first.wert; } }