This method is supposed to reverse a stack by making a new stack and pushing popped items from this stack to that and then returning the reverted stack. When I run some tests, it returns an empty stack in stead. Any clues?
public LinkedStack<E> reversed() { LinkedStack<E> that= new LinkedStack<E>(); if(this.isEmpty()==true){ return this; } else{ while(this.isEmpty()==false) { Node<E> snode=this.top; that.push(snode.getData()); this.pop(); snode=snode.getLink(); } return that; } }