Java Data Struc. Cheat Sheet — Queues

Ayush Arora
1 min readApr 1, 2020

In Java, we broadly categorize Queues into the following two types

  • Bounded Queues (all queues in java.util.concurrent package)
  • Unbounded Queues (all queues in java.util package)

Bounded Queues

Bounded Queues are queues which are bounded by capacity that means we need to provide the max size of the queue at the time of creation.

For example: ArrayBlockingQueue

ArrayBlockingQueue is a bounded, blocking queue backed by an array

BlockingQueue queue = new ArrayBlockingQueue(1024);

queue.put("1");

Object object = queue.take();

Unbounded Queues

Unbounded Queues are queues which are NOT bounded by capacity that means we should not provide the size of the queue.

For example LinkedList

Priority Queues

Class PriorityQueue<E>

An unbounded priority queue based on a priority heap.

References

--

--