Category Java

Stack in Java: Methods, Example

Realtime example of stack in java

A Stack in Java is a collection (or group) of elements stored in the last in first out (LIFO) order. In other words, a stack is a data structure that stores data in last-in, first-out fashion. This means an element…

ArrayDeque in Java

Java ArrayDeque hierarchy diagram

ArrayDeque in Java is a concrete class that creates a dynamic array (resizable array) to store its elements from both sides of the queue. It provides a resizable-array implementation of deque interface. Therefore, it is also known as array double-ended…

Deque in Java

Java ArrayDeque hierarchy diagram

A double ended queue or deque in Java is a linear data structure that supports insertion and removal of elements from both ends (head and tail). It is usually pronounced “deck”, not “de queue”. Java deque is an extended version…

PriorityQueue in Java

Java PriorityQueue hierarchy diagram

A PriorityQueue in Java is a queue or collection of elements in which elements are stored in order of their priority. It is an abstract data type similar to an ordinary queue except for its removal algorithm. An ordinary queue…

Queue in Java

Java Queue interface

A Queue in Java is a collection of elements that implements the “First-In-First-Out” order. In simple words, a queue represents the arrangement of elements in the first in first out (FIFO) fashion. That means an element that is stored as…