Read the following:
'The LinkedList class is often used to store a list, or queue, of work elements --
tasks waiting to be executed. However, the List interface offers far more flexibility
than is needed for this common application, which in general only inserts elements
at the tail and removes elements from the head. But the requirement to support the
full List interface means that LinkedList is not as efficient for this task as it might
otherwise be. The Queue interface is much simpler than List -- it includes only
put() and take() methods, and enables more efficient implementations than
What is the Queue providing us that the LinkedList doesnt?
Why and in what circumstances will I go for a Queue?
In-depth analytical comments will be much appreciated.
Well, like the text explained, Queue is an interface that doesn't require its implementing class to support as many features as the LinkedList class does. The implementing class will be free in how it implements the put and take methods, so this can be done easier and more efficiently.
Queue doesn't offer you anything that LinkedList doesn't, because LinkedList is-a Queue. A very efficient implementation of the Queue interface is the ArrayDeque class.
You use a Queue when you need to perform first-in-first-out operations. An example is a queue of tasks waiting to be handled. New tasks can be added to the back of the queue, and whatever handles the tasks takes old tasks from the front of the queue.
subject: Linkedlist vs Queue - what does this comment mean?