public void replaceAllBy(Stack<T> s){
  elements.clear();
  elements.addAll(s.elements);
  length=elements.size();
}

public void replaceAllBy ( Stack < T > s ) { elements . clear ( ) ; elements . addAll ( s . elements ) ; length = elements . size ( ) ; }
replace all elements in the stack with the elements of another given stack . it first removes all the elements currently in the stack , and then adds all the elements of the provided stack .
