Set is a data structure storing distinct values and mainly used for uniqueness. Getting, adding and removing items from a set is very fast. Usually it is constant time operation[O(1)], however another kind of sets called sorted sets and tree sets used to have logarithmic time operations [O(log(n))] similar to sorted maps. Operation times for set are proportional to that of its map counterparts. This is obvious because in java code, sets are created over maps. In other words, sets are set of keys of the map.
Storage
Storage of items in the set is entirely same as that of the maps. The difference however lies at the value part of the map. Value in map is a final object when it is used as a set. This is used to make sure that set data structure does not waste precious memory.
HashSet
Since java 1.2. Not Synchronized. Items inserted are random. Very good hash based Set data structure. It shows high performance but eats up too much memory. It can be avoided if data size is huge.
TreeSet
Since java 1.2. Not Synchronized. Items inserted are sorted. SortedMap backed data structure. Used to store the distinct data and are sorted in their natural order. The operation time complexity is O(logn) for add, remove, contains operations.
LinkedHashSet
Since java 1.4. Not Synchronized. Items inserted are ordered. An implementation of HashSet with Hashtable. To use LinkedHashSet efficiently, load factor and initial capacity must be chosen wisely.
EnumSet
Since java 1.5. Not Synchronized. Items inserted are ordered. Specially made for enum types. Null values are not permitted in enum set.
ConcurrentSkipListSet
Since java 1.6. Synchronized. Items inserted are sorted. This is skip lists based synchronized SortedSet. remember the size method of this set is not O(1), beacuse size method traverses all elements in the set.