StringTokenizer in Java | Use, Example

StringTokenizer in Java is a utility class that breaks a string into pieces or multiple strings called “tokens”. For example, strings separated by space and tab characters are tokens. These tokens are separated with the help of a delimiter. A Delimiter is a group of characters that separate tokens. Each … Read more

Comparator in Java | Use, Example

Comparator in Java is an interface whose task is to compare objects of a user-defined class when the class does not implement the Comparable interface. In other words, Java Comparator is used when: Objects to be ordered do not have a natural ordering defined by Comparable interface. You want to … Read more

Comparable Interface in Java | Use, Example

Comparable interface in Java defines compareTo() method for comparing objects of the same type. In other words, Comparable interface defines a standard way in which two objects of the same class will be compared. It is mainly used to provide the natural sorting order of objects (elements). The natural ordering … Read more

ArrayDeque in Java | Methods, Example

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 queue or simply array deck. Since ArrayDeque has no capacity … Read more

Deque in Java | Methods, Example

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 of queue to handle a double-ended queue. It extends Queue … Read more

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