Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8671597
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T18:59:17+00:00 2026-06-12T18:59:17+00:00

I have a LinkedList class, which serves as the base for a Queue class,

  • 0

I have a LinkedList class, which serves as the base for a Queue class, which serves as the base for a PrintQueue class.

Here’s my PrintQueue class:

public class PrintQueue<T> {
    private Queue<T> queue;

    public PrintQueue() {
        queue = new Queue<T>();
    }

    public void lpr(String owner, int jobID) {
        queue.enqueue(new Job(owner, jobID));
    }
}

The queue.enqueue(...) line, three from the bottom is resulting in an error:

The method enqueue(T) in the type Queue is not applicable for the arguments (Job)

PrintQueue is a queue of Job objects.

The enqueue method in my Queue class looks like this:

    public void enqueue(T item) {
        queue.addToEnd(item);
    }

And the addToEnd method looks like this:

public void addToEnd(T item) {
    Node<T> itemnode = new Node<T>(item, null); 

    if (isEmpty()) {
        head = itemnode;
    }
    else {
        Node<T> curr = head;

        while (curr.getNext()!=null) {
            curr= curr.getNext();
        }

        curr.setNext(itemnode);
    }

    count++;

}

Why isn’t this working? All three classes (PrintQueue, Queue and LinkedList) are generic classes .

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T18:59:18+00:00Added an answer on June 12, 2026 at 6:59 pm

    You’re trying to create a Queue<T> for some arbitrary type T – but then you’re trying to enqueue a Job.

    What do you think it means to enqueue a Job on a Queue<String> for example?

    Do you really need PrintQueue to be generic? I suspect you just want:

    public class PrintQueue {
        private final Queue<Job> queue;
    
        public PrintQueue() {
            queue = new Queue<Job>();
        }
    
        public void lpr(String owner, int jobID) {
            queue.enqueue(new Job(owner, jobID));
        }
    }
    

    (Additionally, it’s not clear why you’ve got your own Queue class, when there are various good queues in the built-in class library… ones that don’t have O(N) “add to end” behaviour, too…)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

If I have a collection of objects: public class Party { LinkedList<Guy> partyList =
I have a class like this - class Messages { ... LinkedList<String> inputs; LinkedList<String>
I have a class class PCB { public: struct { string type; **linklist list;**//refer
We have something like List lst = new LinkedList(); which shows that List is
I have made a LinkedList to store State objects which is a class I
this is a sample code from delete function in my LinkedList class which deletes
Let's say I have a class Employee and a class Company which holds a
I want to test which interfaces a class/interface is implementing. So I have a
I have code that looks like this: public class Polynomial { List<Term> term =
I've a Tuple class which has: private class Tuple { private int fileno; private

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.