Question: Define a class Stack that contains an ArrayList of Objects with the following methods: a.isEmpty()a boolean method to determine of the stack is empty. b.getSize()a
Define a class Stack that contains an ArrayList of Objects with the following methods:
a.isEmpty()a boolean method to determine of the stack is empty.
b.getSize()a method that return number of elements in the stack.
c.peek()returns the last (top) element of the stack but does not remove it.
d.pop()removes and returns the last element in the stack.
e.push()places an object onto the top (last) position of the stack.
f.toString()displays the content of the stack.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
