Stack implementation in Java
}catch (Exception e){
    System.out.println("Popping off an empty stack:" + e);
}



Why? You should be able to know if your stack is empty before you even try to pop it. And in that case, any consumer of that Stack class is going to expect an exception to be thrown.

Actually, something's fishy about that catch block.

Stack&lt;int&gt; foo = new Stack&lt;int&gt;();
foo.pop();


What does that do? head is null, you've made sure... twice.

Once here:


private Node head = null;



And another here:


public Stack(){
    size = 0;
    head = null;
}



The constructor seems redundant.

Now, with head being null, foo.pop() will throw a rather surprising NPE, despite that try/catch block seemingly handling the "stack is empty!" case.

You should avoid having that NPE thrown, and instead throw an EmptyStackException, for which your consumer code will be thankful.