Create a new class named genericstack that specifies a type


Question: Create a new class named GenericStack that specifies a type variable that gives for generics.

Declare a LinkedList that hold the elements in the stack. Then use the LinkedList to implement the methods shown above.

Create a class that uses the GenetricStack class

Call the class GenericStackApp. Declare a generick stack at the beginning of the main method that will store String Objects.

Include code to the main method that uses the push method to include at least three items to the stack. After each item is added, display its value at the console (you'll need to use a string literal to do this).

Then, use the size method to return the number of items in the stack and display that value.

Use the peek method to return the first item and show that item, and use the size method to return the number of items again and show that value.

Use the pop method to return each item, displaying it as it's returned, and show the number of items one more time.

Display:

Push: Apples

Push: Oranges

Push: Bananas

The stack contains 3 items

Peek: Bananas

The stack contains 3 items

Pop: Bananas

Pop: Oranges

Pop:Apples

The stack contains 0 items

I am having difficulty with this problem because I do not know where to start with.

Request for Solution File

Ask an Expert for Answer!!
JAVA Programming: Create a new class named genericstack that specifies a type
Reference No:- TGS0961962

Expected delivery within 24 Hours