@Override public int pop() { // TODO Auto-generated method stub ListNode temp = head; head = head.next; return temp.getVal(); }
@Override public void push(int val) { // TODO Auto-generated method stub ListNode current = new ListNode(val); if (head == null) { head = current; } else { ListNode iterNode = head; while (iterNode.next != null) { iterNode = iterNode.next; } iterNode.next = current; } }
@Override public int peek() { // TODO Auto-generated method stub return head.getVal(); }