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
Tag: java set
Java Collections: Problem Solving with Java Sets
In this article we will examine an extremely scaled-down version of a real life problem that can be solved using Java Set. For appreciating the choices made in the sample program presented here, you need to understand the differences between HashSet, LinkedHashSet and TreeSet. Problem Description A web based startup wishes to reward (distribute bonus, if you… Continue reading Java Collections: Problem Solving with Java Sets
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