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
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
Get step-by-step solutions from verified subject matter experts
