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

  • Home
  • SEARCH
  • 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 3679474
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T03:27:48+00:00 2026-05-19T03:27:48+00:00

When I try: Queue<Integer> q = new Queue<Integer>(); The compiler is giving me an

  • 0

When I try:

Queue<Integer> q = new Queue<Integer>();

The compiler is giving me an error. Any help?

Also, if I want to initialize a queue do I have to implement the methods of the queue?

  • 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-05-19T03:27:49+00:00Added an answer on May 19, 2026 at 3:27 am

    A Queue is an interface, which means you cannot construct a Queue directly.

    The best option is to construct off a class that already implements the Queue interface, like one of the following: AbstractQueue, ArrayBlockingQueue, ArrayDeque, ConcurrentLinkedQueue, DelayQueue, LinkedBlockingQueue, LinkedList, PriorityBlockingQueue, PriorityQueue, or SynchronousQueue.

    An alternative is to write your own class which implements the necessary Queue interface. It is not needed except in those rare cases where you wish to do something special while providing the rest of your program with a Queue.

    public class MyQueue<T extends Tree> implements Queue<T> {
       public T element() {
         ... your code to return an element goes here ...
       }
    
       public boolean offer(T element) {
         ... your code to accept a submission offer goes here ...
       }
    
       ... etc ...
    }
    

    An even less used alternative is to construct an anonymous class that implements Queue. You probably don’t want to do this, but it’s listed as an option for the sake of covering all the bases.

    new Queue<Tree>() {
       public Tree element() {
         ...
       };
    
       public boolean offer(Tree element) {
         ...
       };
       ...
    };
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Try loading this normal .jpg file in Internet Explorer 6.0. I get an error
I have an application which spawns a new thread when a user asks for
I have successfully created the message queue by using the following command: msgIdHareTurtle =
I have the following piece of code where I try to override a method:
I have some threads fishing into a queue for jobs, something like this: class
I want to transmit data from a Queue using Twisted. I currently use a
I have written a TCPIP server that implements a FileSystemWatcher and fills a queue
I have a Windows Service that retrieves messages from a RabbitMQ queue. The service
I have the following class: #include <string> #include <stack> #include <queue> #include map.h using
IE is giving me an undefined NAN when i try to view the calender...

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.