3

I have a class Queue that fully implements the Queue interface, however I have no idea on how to actually initialize the queue in my main Code.

Queue<T> q = ???

I have been searching the internet for the answer for 30+ minutes AND consulted the Java API docs, but I am outright stuck. I know this is a simple question, and because of that its driving me insane. Any help?

3 Answers 3

4

Queue is an interface. You can't instantiate an interface directly. Instead, choose an existing implementation. For example:

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

or

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

ArrayDeque is faster .

Sign up to request clarification or add additional context in comments.

Comments

1
Queue<T> q = new Queue <T> (allParametersGoHere);

2 Comments

"I have a class Queue that fully implements the Queue interface"
Thanks for both answers!
0

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.