A Java Map is an aggregation of values, each of which is associated with exactly one key. The distinguishing feature of a Java Map is that keys are unique and every key is associated with a value. The same value may be associated with two keys but two values can’t have the same key. A key maps to exactly one… Continue reading Java Map
Tag: collections
Java Collections: EnumSet with Example
Enumset is a special kind of Java Set which is optimized for storing enum constants. Because Java is a strongly typed language, an EnumSet stores exactly one type of enum constants. Since the universe (the range of permitted values)of enum type is always finite, an EnumSet can be optimized in ways that other Set implementations… Continue reading Java Collections: EnumSet with Example
Java Collections: Differences between TreeSet, LinkedHashSet and HashSet
To effectively use Java Sets a Java programmer must understand the difference between TreeSet, LinkedHashSet and HashSet in Java. All three of them implement the Set interface and therefore don’t allow duplicate elements. Still, there are a few subtle differences in performance and usage patterns that every Java programmer must be aware of. Differences between TreeSet, LinkedHashSet and… Continue reading Java Collections: Differences between TreeSet, LinkedHashSet and HashSet