Question: The following class GenericStack is implemented using composition. Define a new generic stack class that extends ArrayList. public class GenericStack { private java.util.ArrayList list -

 The following class GenericStack is implemented using composition. Define a new

The following class GenericStack is implemented using composition. Define a new generic stack class that extends ArrayList. public class GenericStack { private java.util.ArrayList list - new java.util.ArrayListo: public int getSize() { return list.size(): } public E peek() { return list.get (getSize() - 1); ) public void push(E ) { list.add(0); 3 public E pop() { Eo - list.get(getSize() - 19: list.remove(getSize() - 1): return o; } public boolean is Empty() { return list. 1sEmpty(); > @Override public String toString() { return "stack: + list.toString()

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!