Tutorial by Examples

PriorityQueue is a data structure. Like SortedSet, PriorityQueue sorts also its elements based on their priorities. The elements, which have a higher priority, comes first. The type of the PriorityQueue should implement comparable or comparator interface, whose methods decides the priorities of the ...
The java.util.LinkedList class, while implementing java.util.List is a general-purpose implementation of java.util.Queue interface too operating on a FIFO (First In, First Out) principle. In the example below, with offer() method, the elements are inserted into the LinkedList. This insertion operat...
What is a Stack? In Java, Stacks are a LIFO (Last In, First Out) Data structure for objects. Stack API Java contains a Stack API with the following methods Stack() //Creates an empty Stack isEmpty() //Is the Stack Empty? Return Type: Boolean push(Item item) /...
A BlockingQueue is an interface, which is a queue that blocks when you try to dequeue from it and the queue is empty, or if you try to enqueue items to it and the queue is already full. A thread trying to dequeue from an empty queue is blocked until some other thread inserts an item into the queue. ...
Basics A Queue is a collection for holding elements prior to processing. Queues typically, but not necessarily, order elements in a FIFO (first-in-first-out) manner. Head of the queue is the element that would be removed by a call to remove or poll. In a FIFO queue, all new elements are inserted a...
A Deque is a "double ended queue" which means that a elements can be added at the front or the tail of the queue. The queue only can add elements to the tail of a queue. The Deque inherits the Queue interface which means the regular methods remain, however the Deque interface offers addit...

Page 1 of 1