1. Implement a class Stack (LIFO)
with the following methods:
•
public Stack(int n)
Create a stack with place for n objects
•
public void push(String s)
Inserts “s” into the stack
•
public String pop()
Retrieves and removes the top element of the stack
•
public boolean isEmpty()
Checks whether the stack is empty
•
public String toString()
Returns with all elements of the stack in a String
2. Write a main program in
another class, which:
• creates 2 stacks
• pushes some strings into the first stack
• then prints out the content of the first stack on the screen
• in a cycle takes out (pop) all the element of the first stack and inserts (push) them into the second stack
• Finally prints out the content of the second stack on the screen.