/** * Beschreiben Sie hier die Klasse List_T_. * * @author (Ihr Name) * @version (eine Versionsnummer oder ein Datum) */ public class Stack { private Node first; public Stack() { first = null; } public boolean isEmpty() { if (first == null) return true; return false; } public T top(int n) { if (first == null) return null; return first.wert; } public void push(T val) { Node neu = new Node (); neu.wert = val; neu.next = first; first = neu; } public T pop(int n) { if (first == null) return null; T tmp = first.wert; // wert von first (=0) speichern first = first.next; //first "pfeil" auf den nächsten return tmp;//wert ausgeben } public String toString(){ // glaub um halt alles schön auszugeben String result = ""; Node current = first; while (current != null){ result += current.wert + ", "; current = current.next; } return result; } }