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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started