Question: Please use JAVA Write a generic stack class to implement a stack using an ArrayList object. Define the data member and methods listed below: A

Please use JAVA

Write a generic stack class to implement a stack using an ArrayList object. Define the data member and methods listed below:

A single data member:

An ArrayList object

Instance Methods:

zero-parameter constructor instantiate an empty stack

copy constructor

public boolean isEmpty(): returns true if the stack is empty

public void push(T): pushes the given parameter on the stack

public T pop() : pops an element from the stack

public T lookUp(): returns the value of the top element without removing it from the stack

When a method that returns a value cannot perform its prescribed operation, return null.

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!