Question: Write a method called copyStack that copies the contents of one stack into another (which is not empty). The method must take as parameter a
Write a method called copyStack that copies the contents of one stack into another (which is not empty). The method must take as parameter a source stack and Boolean flag reverse and copy the contents of the given stack into a destination stack and return the same. Your method should also allow the source stack to be copied in reverse order based on the value of the flag reverse. If reverse is true, the source stack should be copied in reverse order. If reverse is false, the content on source stack is placed in destination stack in such a way that the final stack would maintain the original order of the data.
Write the code in java and explain it to me.Thanks.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
