public class Stack<E extends Object> {
private Node<E> head;
private int N;
private class Node<E> {
private Node<E> next;
private E value;
}
public push(E e) {
Node<E> oldHead = head;
head = new Node<>();
head.value = e;
head.next = oldHead;
N ++;
}
public boolean isEmpty() {return N == 0;}
public E pop() {
if(isEmpty()) return null;
E e = head.value;
head = head.next;
N --;
return e;
}
}