A queue is a collection interface that holds the objects. collections are designed to hold elements prior to processing. Queues provide additional insertion, extraction, and inspection operations along with the collection operations.
Mostly but not necessarily queues, order elements in a FIFO (first-in-first-out) manner. It is independent of the order used, while the head of the queue is that element which would be removed by a call to remove() or poll(). In case of FIFO queue, elements are inserted from the tail of the queue. While different queues may use different placement rules. Every Queue implementation must specify its ordering properties.
The offer() method inserts an element if possible, otherwise returning false that is designed for normal failures rather than exceptional occurrences such as fixed capacity (or bounded) queue. Methods remove() and poll() are used to remove the element that returns the head of the queue. Methods remove() and poll() are different only in that remove() method throws an exception whenever the queue is empty, while the method poll() returns null.
Methods element() and peek() returns rather than removing the head of the queue.
To know more about java queue go to the link:
Liked it! Share this Tutorial