PriorityQueue in Java | Methods, Example

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 is a first-in-first-out (FIFO) data structure. In FIFO, elements are added … Read more

Queue in Java | Methods, Example

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 a first element into the queue will be removed first … Read more

SortedMap in Java | Methods, Example

SortedMap in Java is an interface that is a subinterface of Map interface. The entries in the map are maintained in sorted ascending order based on their keys. In simple words, it guarantees that the entries are maintained in ascending key order. It allows very efficient manipulations of subsets of … Read more

What is Hashtable in Java with Example

Hashtable class in Java is a concrete implementation of abstract Dictionary class. It is a data structure similar to Java HashMap that can store a collection of elements (objects) in the form of key-value pairs (entries). Key objects must implement hashCode() and equals() methods to store and retrieve values from … Read more

EnumMap in Java | Methods, Example

EnumMap in Java is a concrete class that provides Map implementation whose keys are of the enum type. All the keys in the EnumMap must originate from a single enum type that is specified, implicitly or explicitly, when the map is created. Enum maps are represented internally as an array … Read more

IdentityHashMap in Java | Methods, Example

IdentityHashMap in Java is a concrete class that is similar to HashMap except that it uses reference equality (==) when comparing entries (keys and values). In simple words, Java IdentityHashMap uses reference equality (==) instead of object equality (equals() method) when comparing keys and values. While comparing keys, HashMap uses … Read more