public class Stack
{
    public class Knoten
    {
        Object wert;
        Knoten next;

        public Knoten(Object w)
        {
            wert = w;
            next = null;
        }
    }

    private Knoten tos;

    public Stack()
    {
        tos = null;
    }

    public boolean isEmpty() 
    {
        return (tos == null);
    }

    public void push(Object x) 
    {
        Knoten neu = new Knoten(x);
        neu.next = tos;
        tos = neu;
    }

    public void pop() 
    {
        if (!isEmpty()) tos = tos.next;
    }

    public Object top() 
    {
        if (!isEmpty())
            return tos.wert;
        else
            return null;
    }
}