Create a class that uses the genetricstack class

Assignment Help JAVA Programming
Reference no: EM13708697

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.

Reference no: EM13708697

Questions Cloud

Computes the product of all elements in a vector : Write a C function that computes the product of all elements in a vector x of dimension n. The elements of the vector are stored in a double array of size n.
How much of each solution should be mixed to prepare buffer : Question- You need to prepare 100 ml of a pH = 4.00 buffer solution using 0.100 M Benzoinc acid (pka = 4.20) and 0.120 M sodium benzoate. How much of each solution should be mixed to prepare this buffer
Prepare a c function that returns the number of elements : Prepare a C function that returns the number of elements smaller than 3.0 in an array - make a function returns the number of elements.
What is the volume occupied by argon gas at a pressure : Question- What is the volume occupied by 22.3g of argon gas at a pressure of 1.48atm and a temperature of 469K. Express your answer with the appropriate units.
Create a class that uses the genetricstack class : Create a new class named GenericStack that specifies a type variable that gives for generics - 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.
The formal charges of all atoms in the correct structure : Question- Write Lewis structure that obeys the octet rule for OCS and assign formal charges to each atom. Draw the molecule by placing atoms on the grid and connecting them with bonds. Include all lone pairs of electrons. Show the formal charges o..
Binary search algorithm : How many elements must be compared to search a list of 20,000 elements using the binary search algorithm - What will this statement do?
What is the final state of hydrogen atom : Question- A ground-state hydrogen atom absorbs a photon of light that has a wavelength of 97.2 nm. It then gives off a photon that has a wavelength of 486nm. What is the final state of hydrogen atom
Draw an eer diagram with the given entities : Draw an EER Diagram with the given entities with the attributes listed - implement EER Diagram.

Reviews

Write a Review

JAVA Programming Questions & Answers

  Write a recursive method to produce a pattern

Write a recursive method to produce a pattern of n lines of asterisks.

  Using an array in java

Using an array in Java - have a list of keywords from a web service and have to print out the list of keywords on the screen with one keyword on each line. This is my code

  Simple java program that implements some basic file

Your code will prompt the user to enter a file name. If this file does not exist the program will produce an error message and exit. Otherwise the program will open the file and read a line from the file, reverse the line, and then print the line to ..

  Display student details and classes in applet

Display student details and classes they have enrolled in Applet. The Applet should have following features. Update and View.

  Determine product a inferior or normal good

Research illustrates that prices of related goods are given by Py = $5,900 and ; Pz = $90, while average income of individuals consuming this product is M = $55,000. Is X inferior or normal good?

  Implement a generic class set

Implement a generic class Set that maintains a set of items of generic type T using the class LinkedList in the Java API. Your Set class must provide the subsequent functionality:

  Initialized the array of words by an assignment statement.

modify the following program . The program from Lab 4 initialized the array of words by an assignment statement.

  Write an expression those results in a string consisting

Write an expression those results in a string consisting of the third through tenth characters of the strings. Make this program using java programming.

  Write java program to compute how much federal need to pay

Write a java application to calculate how much federal and state tax you need to pay. The program should accomplish the following task.

  What is an illustration of a hypothesis test please explain

what is an example of a hypothesis test? please describe the context of the problemissue that you encountered what the

  Write an application that displays all even numbers

Write an application that displays all even numbers from 2 to 100 inclusive, and that starts a new line after every multiple of 20 ( 20, 40, 60, and 80). Save the file as EvenNums. java

  Number of space characters in a string

Write a loop that counts the number of space characters in a string - You need to implement a program to find the number of spaces.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd