public void appendToTail(int d) { Node end = new Node(d); Node n = this; while (n.next != null) { n = n.next; } n.next = end; }
public void push(int d) { Node item = new Node(d); item.next = top; top = item; }
public int? pop() { if (top != null) { Node item = top; top = top.next; return item.data; } return null; }