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?
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 .
Queue<T> q = new Queue <T> (allParametersGoHere);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With