Question: In Java Purpose: Learn how stacks are implemented and used Finish implementing stack classes called ListStack and ArrayStack using a linked list and ArrayList respectively.


In Java
Purpose: Learn how stacks are implemented and used Finish implementing stack classes called ListStack and ArrayStack using a linked list and ArrayList respectively. You are given 3 classes, ListStack CharNode and ArrayStack. The CharNode has the following fields and methods implemented: A public character mychar A next node pointer nextNode A constructor to create a new node with myChar initialized and nextNode null A constructor to create a new node with all fields initialized to parameters passed in The List/ArrayStack classes have the following fields and methods already implemented An integer size that keeps track of how many characters are in the stack The ArrayStack class has an ArrayList of characters called charray and The ListStack class has a linked list of CharNode objects called charlist A constructor that initializes the size to zero and ArrayStack to an empty ArrayList Or ListStack to null A push method that takes a character and adds it to the top of the stack at the head of the list or 0 index of the ArrayList, increments the size and returns nothing
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
