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