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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!