Question: 3. (5 points) Write a Java class MyStack (not main) that represents a stack for holding objects. A stack is a LIFO (Last In First

 3. (5 points) Write a Java class MyStack (not main) that

3. (5 points) Write a Java class MyStack (not main) that represents a stack for holding objects. A stack is a LIFO (Last In First Out) data type with push() (place on top of the stack) and pop() (retrieve the top object from the stack) methods. Use the following UML diagram and description to write the class. MyStack -list: ArrayList A list to store elements. +isEmpty(): boolean +getSize(): int +peek(): Object +pop(): Object +push(o: Object): void Returns true if this stack is empty. Returns the number of elements in this stack. Returns the top element in this stack without removing it. Returns and removes the top element in this stack. Adds a new element to the top of this stack

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!