Question: I'm a beginner in JAVA Create a generic queue class, implementing it using a linked list . Define a generic node class inside the queue

I'm a beginner in JAVA

Create a generic queue class, implementing it using a linked list. Define a generic node class inside the queue class that will be made up of a data member of type T and a data member of the generic node type. The queue class will have three data members:

An object of the generic node class to store the reference to the first node in the queue

An object of the generic node class to store the reference to the last node in the queue

An integer to store the number of nodes in the queue

Code the following instance methods:

the zero-parameter constructor setting up an empty queue

public void addToQueue( T ) adds an element to the queue

public T deleteFromQueue( ) removes an element from the queue

public boolean isEmpty() returns true if the queue is empty and false otherwise

public int size() returns the number of elements in the queue

public T lookUp() returns the first element in the queue without deleting it

public void clearQueue() clears the queue ( reset it to be empty )

public String toString() creates a string with the content of the queue

Write your own small main method (in a separate file) to test your queue class thoroughly.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!