Category Java

HashMap in Java

Java HashMap hierarchy diagram

HashMap in Java is an unordered collection that stores elements (objects) in the form of key-value pairs (called entries). It is expressed as HashMap<Key, Value>, or HashMap<K, V>, where K stands for key and V for value. Both Key and…

LinkedHashSet in Java

Java LinkedHashSet Hierarchy diagram

LinkedHashSet in Java is a concrete class that implements set interface and extends HashSet class with a doubly linked list implementation. It internally uses a linked list to store the elements in the set. It was added in Java 1.4…

TreeSet in Java

TreeSet hierarchy in Java

A TreeSet in Java is another important implementation of the Set interface that is similar to the HashSet class, with one added improvement. It sorts elements in ascending order while HashSet does not maintain any order. Java TreeSet implements SortedSet…

How to Iterate Map in Java

We have known in the previous tutorial, a map in Java is a container object that stores elements in the form of key and value pairs. If the key is provided, its associated value can be retrieved easily. Keys must…

Map in Java

Map in Java

A map in Java is a container object that stores elements in the form of key and value pairs. A key is a unique element (object) that serves as an “index” in the map. The element that is associated with…