TreeSet in Java

What is TreeSet 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 which constructor is used. Like HashSet, TreeSet also implements Set interface. Like HashSet, TreeSet allows to store only unique elements in their objects. HashSet is much […]

Read More

HashSet in Java

What is HashSet HashSet extends AbstractSet and is an implementation of Set interface. HashSet also implements Serializable and Cloneable interfaces. HashSet is backed by hash table(actually HashMap instance), i.e., the HashSet uses hash table(HashMap) to store collection elements. Like HashMap, it allows null only one element.

Read More