Challenge for Writing Generic Classes and Methods


Create a generic class Stack<T> that can be used to represent stacks of objects of type T. The class should include methods push(), pop(), and isEmpty(). Inside the class, use an ArrayList to hold the items on the stack.

The included boilerplate will push each number from input onto the the stack, but will pop() and print off an item when it reaches a -1.

Please sign in or sign up to submit answers.

Alternatively, you can try out Learneroo before signing up.

Contact Us
Sign in or email us at [email protected]