Java Collections Archive
TreeMap class A TreeMap contains values based on the key. It implements the NavigableMap interface and extends AbstractMap class. It contains only unique elements. It cannot have null key but can have multiple null values. …
This class extends HashMap and maintains a linked list of the entries in the map, in the order in which they were inserted. This allows insertion-order iteration over the map. That is, when iterating a …
What is Hashing? Hashing in its simplest form, is a way to assigning a unique code for any variable/object after applying any formula/algorithm on its properties. A true Hashing function must follow this rule: Hash …
HashMap class extends AbstractMap and implements Map interface. It uses a hashtable to store the map. This allows the execution time of get() and put() to remain same. HashMap has four constructor. HashMap() HashMap(Map< ? …
The Map interface is not an extension of Collection interface. Instead the interface starts of it’s own interface hierarchy, for maintaining key-value associations. The interface describes a mapping from keys to values, without duplicate keys, …
Several difference between HashSet and TreeSet are similar to what we discussed as difference between TreeMap and HashMap. Anyway Set and Map are two completely different interface so we will revisit those differences here. Probably …
public class TreeSet<E> extends AbstractSet<E> implements NavigableSet<E>, Cloneable, Serializable A NavigableSet implementation based on a TreeMap. The elements are ordered using their natural ordering, or by a Comparator provided at set creation time, depending on …